note updata
Signed-off-by: zhuhong <1870495044@qq.com>
79
OAT.xml
Normal file
@ -0,0 +1,79 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Copyright (c) 2021 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.
|
||||
|
||||
This is the configuration file template for OpenHarmony OSS Audit Tool, please copy it to your project root dir and modify it refer to OpenHarmony/tools_oat/README.
|
||||
|
||||
-->
|
||||
|
||||
<configuration>
|
||||
<oatconfig>
|
||||
<licensefile></licensefile>
|
||||
<policylist>
|
||||
<policy name="projectPolicy" desc="">
|
||||
<!--policyitem type="compatibility" name="GPL-2.0+" path="abc/.*" desc="Process that runs independently, invoked by the X process."/-->
|
||||
<!--policyitem type="license" name="LGPL" path="abc/.*" desc="Dynamically linked by module X"/-->
|
||||
<!--policyitem type="copyright" name="xxx" path="abc/.*" rule="may" group="defaultGroup" filefilter="copyrightPolicyFilter" desc="Developed by X Company"/-->
|
||||
</policy>
|
||||
</policylist>
|
||||
<filefilterlist>
|
||||
<filefilter name="defaultFilter" desc="Files not to check">
|
||||
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
|
||||
</filefilter>
|
||||
<filefilter name="defaultPolicyFilter" desc="Filters for compatibility,license header policies">
|
||||
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
|
||||
</filefilter>
|
||||
<filefilter name="copyrightPolicyFilter" desc="Filters for copyright header policies">
|
||||
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
|
||||
</filefilter>
|
||||
<filefilter name="licenseFileNamePolicyFilter" desc="Filters for LICENSE file policies">
|
||||
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
|
||||
</filefilter>
|
||||
<filefilter name="readmeFileNamePolicyFilter" desc="Filters for README file policies">
|
||||
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
|
||||
</filefilter>
|
||||
<filefilter name="readmeOpenSourcefileNamePolicyFilter" desc="Filters for README.OpenSource file policies">
|
||||
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
|
||||
</filefilter>
|
||||
<filefilter name="binaryFileTypePolicyFilter" desc="Filters for binary file policies">
|
||||
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
|
||||
</filefilter>
|
||||
|
||||
</filefilterlist>
|
||||
<licensematcherlist>
|
||||
<!--licensematcher name="uvwxyz License" desc="If the scanning result is InvalidLicense, you can define matching rules here. Note that quotation marks must be escaped.">
|
||||
<licensetext name="
|
||||
uvwxyz license textA xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
" desc=""/>
|
||||
<licensetext name="
|
||||
uvwxyz license textB xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
" desc=""/>
|
||||
</licensematcher-->
|
||||
</licensematcherlist>
|
||||
</oatconfig>
|
||||
</configuration>
|
36
README.en.md
@ -1,36 +0,0 @@
|
||||
# applications_note
|
||||
|
||||
#### Description
|
||||
{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**}
|
||||
|
||||
#### Software Architecture
|
||||
Software architecture description
|
||||
|
||||
#### Installation
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
|
||||
#### Instructions
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
|
||||
#### Contribution
|
||||
|
||||
1. Fork the repository
|
||||
2. Create Feat_xxx branch
|
||||
3. Commit your code
|
||||
4. Create Pull Request
|
||||
|
||||
|
||||
#### Gitee Feature
|
||||
|
||||
1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md
|
||||
2. Gitee blog [blog.gitee.com](https://blog.gitee.com)
|
||||
3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore)
|
||||
4. The most valuable open source project [GVP](https://gitee.com/gvp)
|
||||
5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help)
|
||||
6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
|
140
README_zh.md
Normal file
@ -0,0 +1,140 @@
|
||||
# 备忘录源码开发说明
|
||||
## 1. 项目介绍
|
||||
备忘录应用是OpenHarmony中预置的应用,为用户提供文本编辑以及保存功能。
|
||||
|
||||
## 2. 工程结构
|
||||
### 目录结构
|
||||
```
|
||||
/applications/standard/note
|
||||
├─common
|
||||
│ ├─component
|
||||
│ │ └─src
|
||||
│ │ └─main
|
||||
│ │ ├─ets
|
||||
│ │ │ └─default # 界面基本组件
|
||||
│ │ └─resources # 资源配置文件存放目录
|
||||
│ └─utils
|
||||
│ └─src
|
||||
│ └─main
|
||||
│ ├─ets
|
||||
│ │ └─default
|
||||
│ │ ├─baseUtil # 数据处理
|
||||
│ │ ├─constants # 常量定义
|
||||
│ │ └─model
|
||||
│ │ ├─databaseModel # 数据格式定义
|
||||
│ │ └─searchModel # 搜索数据格式定义
|
||||
│ └─resources # 资源配置文件存放目录
|
||||
├─figures # readme的截图
|
||||
└─product
|
||||
├─phone
|
||||
│ └─src
|
||||
│ └─main
|
||||
│ ├─ets
|
||||
│ │ └─MainAbility
|
||||
│ │ ├─pages # 手机主页面设置
|
||||
│ │ └─res # 预置图片
|
||||
│ └─resources # 资源文件
|
||||
└─tablet
|
||||
└─src
|
||||
└─main
|
||||
├─ets
|
||||
│ └─MainAbility
|
||||
│ ├─pages # 平板主页面设置
|
||||
│ └─res # 预置图片
|
||||
└─resources # 资源文件
|
||||
```
|
||||
### 整体架构
|
||||
|
||||
|
||||
|
||||
![](./figures/note.png)
|
||||
|
||||
## 3. 签名打包
|
||||
### 签名
|
||||
#### 签名文件的获取
|
||||
1. 生成签名文件可参考https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/quick-start/configuring-openharmony-app-signature.md
|
||||
|
||||
#### 签名文件的配置
|
||||
打开项目工程,选择 File → Project Structure
|
||||
|
||||
![](./figures/signature_1.png)
|
||||
|
||||
选择 Modules → Signing Configs,将对应的签名文件配置如下,完成后点击Apply,再点击OK。
|
||||
密码为生成签名文件时的密码,如果使用默认的签名文件,则使用默认密码123456。
|
||||
|
||||
![](./figures/signature_2.png)
|
||||
|
||||
配置完成后,对应的build.gradle文件中会出现如下内容
|
||||
|
||||
![](./figures/signature_3.png)
|
||||
|
||||
### 打包
|
||||
1. 选择Build → Build Haps(s)/APP(s) → Build Hap(s)
|
||||
|
||||
![](./figures/ds_build_haps.png)
|
||||
|
||||
2. 编译完成后,hap包会生成在工程目录下的 `\build\outputs\hap\release\`路径下(如果没有配置签名,则只会生成未签名的hap包)
|
||||
|
||||
![](./figures/ds_ohosbuild_output_dir_release.png)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## 4. 安装、调试
|
||||
|
||||
### 应用安装
|
||||
|
||||
将设备通过调试线链接电脑,IDE上显示已链接设备,点击开始按钮即可安装并拉起应用:
|
||||
|
||||
![](./figures/install.png)
|
||||
|
||||
|
||||
|
||||
|
||||
### 应用调试
|
||||
|
||||
#### log打印
|
||||
|
||||
- 在程序中添加 log
|
||||
|
||||
```JS
|
||||
console.info("note log info");
|
||||
```
|
||||
|
||||
可以在DevEco Studio中查看log
|
||||
![](./figures/ds_hilog_window.png)
|
||||
|
||||
#### log获取及过滤
|
||||
|
||||
- log获取
|
||||
|
||||
将hdc_std的环境变量配置好,将log输出至文件
|
||||
|
||||
![](./figures/hdc_std.png)
|
||||
|
||||
```
|
||||
hdc_std shell hilog > 输出文件名称
|
||||
```
|
||||
|
||||
例:
|
||||
在真实环境查看log,将全log输出到当前目录的hilog.log文件中
|
||||
|
||||
```
|
||||
hdc_std shell hilog > hilog.log
|
||||
```
|
||||
|
||||
- log过滤
|
||||
|
||||
在命令行窗口中过滤log
|
||||
|
||||
```
|
||||
hilog | grep 过滤信息
|
||||
```
|
||||
|
||||
例:过滤包含信息 Label 的 hilog
|
||||
|
||||
```
|
||||
hilog | grep Label
|
||||
```
|
||||
|
@ -17,27 +17,29 @@ import FolderData from '../../../../../../common/utils/src/main/ets/default/mode
|
||||
import NoteData from '../../../../../../common/utils/src/main/ets/default/model/databaseModel/NoteData.ets'
|
||||
import {circleColorArray, fontColorArray} from '../../../../../../common/utils/src/main/ets/default/model/NoteBaseData.ets'
|
||||
import {SysDefFolderUuid, DeleteFileType, FolderType} from '../../../../../../common/utils/src/main/ets/default/model/databaseModel/EnumData.ets'
|
||||
import GlobalResourceManager from '../../../../../../common/utils/src/main/ets/default/baseUtil/GlobalResourceManager.ets';
|
||||
import GlobalResourceManager from '../../../../../../common/utils/src/main/ets/default/baseUtil/GlobalResourceManager.ets'
|
||||
import FolderUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/FolderUtil.ets'
|
||||
import NoteUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/NoteUtil.ets'
|
||||
|
||||
@CustomDialog
|
||||
export struct NewOrEditFolderDialog {
|
||||
newOrEditFolderDialogCtl: CustomDialogController;
|
||||
newOrEditFolderDialogCtl: CustomDialogController
|
||||
confirm: (color: string, name: string) => void
|
||||
@State inputName: string = "";
|
||||
private oriInputName: string = "";
|
||||
private oriSelectedColor: string = "";
|
||||
private editFolderUuid: string = "";
|
||||
private dialogType: number = 0; // 0表示新建文件夹 1表示修改文件夹
|
||||
@State isExisted: boolean = false;
|
||||
@State inputName: string = ""
|
||||
private oriInputName: string = ""
|
||||
private oriSelectedColor: string = ""
|
||||
private editFolderUuid: string = ""
|
||||
private dialogType: number = 0 // 0表示新建文件夹 1表示修改文件夹
|
||||
@State isExisted: boolean = false
|
||||
@StorageLink('AllFolderArray') AllFolderArray: FolderData[] = AppStorage.Link('AllFolderArray')
|
||||
@Consume('SelectedColor') selectedColor: string;
|
||||
@Consume('SelectedColor') selectedColor: string
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Text(this.dialogType == 0 ? $r("app.string.createFolder") : $r("app.string.editFolder"))
|
||||
.fontSize(20).height(56).margin({ left: 24 })
|
||||
.fontSize(20)
|
||||
.height(56)
|
||||
.margin({ left: 24 })
|
||||
// folder color choose
|
||||
Flex({ wrap: FlexWrap.NoWrap, justifyContent: FlexAlign.SpaceBetween }) {
|
||||
ForEach(circleColorArray, (colorStr: string) => {
|
||||
@ -65,7 +67,10 @@ export struct NewOrEditFolderDialog {
|
||||
})
|
||||
}.margin({ bottom: 4, left: 24, right: 24 })
|
||||
|
||||
Text($r("app.string.category_already_exist")).fontSize(10).margin({ left: 64 }).fontColor("#FA2A2D")
|
||||
Text($r("app.string.category_already_exist"))
|
||||
.fontSize(10)
|
||||
.margin({ left: 64 })
|
||||
.fontColor("#FA2A2D")
|
||||
.visibility((this.isExisted && this.inputName != this.oriInputName) ? Visibility.Visible : Visibility.None)
|
||||
// button group
|
||||
Flex({ wrap: FlexWrap.Wrap, justifyContent: FlexAlign.SpaceBetween }) {
|
||||
@ -77,7 +82,11 @@ export struct NewOrEditFolderDialog {
|
||||
.onClick(() => {
|
||||
this.newOrEditFolderDialogCtl.close()
|
||||
})
|
||||
Divider().vertical(true).height(15).strokeWidth(1).color($r("app.color.divider_color_e4e4e4"))
|
||||
Divider()
|
||||
.vertical(true)
|
||||
.height(15)
|
||||
.strokeWidth(1)
|
||||
.color($r("app.color.divider_color_e4e4e4"))
|
||||
Text($r("app.string.save"))
|
||||
.opacity(this.inputName == ""
|
||||
|| (this.oriSelectedColor == this.selectedColor && this.inputName == this.oriInputName && this.dialogType == 1)
|
||||
@ -95,7 +104,8 @@ export struct NewOrEditFolderDialog {
|
||||
this.newOrEditFolderDialogCtl.close()
|
||||
this.confirm(this.selectedColor, this.inputName)
|
||||
})
|
||||
}.width('100%').margin({ top: 21, bottom: 25 })
|
||||
}.width('100%')
|
||||
.margin({ top: 21, bottom: 25 })
|
||||
}
|
||||
.width(336)
|
||||
.borderRadius(36)
|
||||
@ -126,12 +136,14 @@ export struct NewOrEditFolderDialog {
|
||||
@Component
|
||||
struct ColorCircleComp {
|
||||
private circleColor: string
|
||||
@Consume('SelectedColor') selectedColor: string;
|
||||
@Consume('SelectedColor') selectedColor: string
|
||||
|
||||
build() {
|
||||
Stack({ alignContent: Alignment.Center }) {
|
||||
Circle({ width: 24, height: 24 }).fill(this.circleColor)
|
||||
Circle({ width: 12, height: 12 }).fill($r("app.color.color_ffffff"))
|
||||
Circle({ width: 24, height: 24 })
|
||||
.fill(this.circleColor)
|
||||
Circle({ width: 12, height: 12 })
|
||||
.fill($r("app.color.color_ffffff"))
|
||||
.visibility(this.circleColor == this.selectedColor ? Visibility.Visible : Visibility.None)
|
||||
}.onClick(() => {
|
||||
this.selectedColor = this.circleColor
|
||||
@ -144,7 +156,7 @@ export struct DeleteDialog {
|
||||
@StorageLink('CheckedNoteArray') CheckedNoteArray: NoteData[] = []
|
||||
@StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray')
|
||||
@StorageLink('AllFolderArray') AllFolderArray: FolderData[] = AppStorage.Link('AllFolderArray')
|
||||
@Consume('SelectedNoteData') selectedNoteData: NoteData;
|
||||
@Consume('SelectedNoteData') selectedNoteData: NoteData
|
||||
@Consume('SelectedFolderData') selectedFolderData: FolderData
|
||||
private multiSelect: boolean = false
|
||||
private deleteFileType = DeleteFileType.NoteData
|
||||
@ -155,23 +167,34 @@ export struct DeleteDialog {
|
||||
Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween }) {
|
||||
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
||||
if (this.deleteFileType == DeleteFileType.FolderData) {
|
||||
Text($r("app.string.delete_tips")).fontSize(14).textAlign(TextAlign.Center).maxLines(1)
|
||||
Text($r("app.string.delete_tips"))
|
||||
.fontSize(14)
|
||||
.textAlign(TextAlign.Center)
|
||||
.maxLines(1)
|
||||
} else {
|
||||
Text(this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ? $r("app.string.deleteNoteComplete") : $r("app.string.deleteNote"))
|
||||
.fontSize(14).textAlign(TextAlign.Center).maxLines(1)
|
||||
.fontSize(14)
|
||||
.textAlign(TextAlign.Center)
|
||||
.maxLines(1)
|
||||
.visibility(this.multiSelect == false || this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ? Visibility.Visible : Visibility.None)
|
||||
if (this.CheckedNoteArray.length ==
|
||||
NoteUtil.getNoteDataArray(this.AllNoteArray, this.selectedFolderData.uuid).length) {
|
||||
Text($r("app.string.deleteAllNote"))
|
||||
.fontSize(14).textAlign(TextAlign.Center).maxLines(1)
|
||||
.fontSize(14)
|
||||
.textAlign(TextAlign.Center)
|
||||
.maxLines(1)
|
||||
.visibility(this.multiSelect == false || this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ? Visibility.None : Visibility.Visible)
|
||||
} else if (this.CheckedNoteArray.length == 1) {
|
||||
Text($r("app.string.deleteNote"))
|
||||
.fontSize(14).textAlign(TextAlign.Center).maxLines(1)
|
||||
.fontSize(14)
|
||||
.textAlign(TextAlign.Center)
|
||||
.maxLines(1)
|
||||
.visibility(this.multiSelect == false || this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ? Visibility.None : Visibility.Visible)
|
||||
} else {
|
||||
Text($r("app.string.deletePartNote", this.CheckedNoteArray.length))
|
||||
.fontSize(14).textAlign(TextAlign.Center).maxLines(1)
|
||||
.fontSize(14)
|
||||
.textAlign(TextAlign.Center)
|
||||
.maxLines(1)
|
||||
.visibility(this.multiSelect == false || this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ? Visibility.None : Visibility.Visible)
|
||||
}
|
||||
}
|
||||
@ -190,7 +213,11 @@ export struct DeleteDialog {
|
||||
.onClick(() => {
|
||||
this.noteDataDeleteDialogCtl.close()
|
||||
})
|
||||
Divider().vertical(true).strokeWidth(1).color($r("app.color.divider_color_e4e4e4")).height(40)
|
||||
Divider()
|
||||
.vertical(true)
|
||||
.strokeWidth(1)
|
||||
.color($r("app.color.divider_color_e4e4e4"))
|
||||
.height(40)
|
||||
Text($r("app.string.delete"))
|
||||
.fontSize(16)
|
||||
.fontColor($r("app.color.delete_color_fa2a2d"))
|
||||
@ -249,7 +276,9 @@ struct NoteDataMoveItemComp {
|
||||
.width(248)
|
||||
.height(55)
|
||||
|
||||
Divider().color($r("app.color.divider_color_e4e4e4")).strokeWidth(1)
|
||||
Divider()
|
||||
.color($r("app.color.divider_color_e4e4e4"))
|
||||
.strokeWidth(1)
|
||||
}
|
||||
.padding({ left: 16 })
|
||||
}
|
||||
@ -270,7 +299,8 @@ export struct NoteDataMoveDialog {
|
||||
Flex({ alignItems: ItemAlign.Center }) {
|
||||
Text($r("app.string.chooseFolder"))
|
||||
.fontSize(20)
|
||||
}.height(56).width(288)
|
||||
}.height(56)
|
||||
.width(288)
|
||||
|
||||
List() {
|
||||
ForEach(this.AllFolderArray, (item) => {
|
||||
@ -293,7 +323,8 @@ export struct NoteDataMoveDialog {
|
||||
.onClick(() => {
|
||||
this.noteDataMoveDialogCtl.close()
|
||||
})
|
||||
}.height(56).width(288)
|
||||
}.height(56)
|
||||
.width(288)
|
||||
}
|
||||
.width(336)
|
||||
.borderRadius(36)
|
||||
@ -306,9 +337,9 @@ export struct NoteDataMoveDialog {
|
||||
|
||||
@CustomDialog
|
||||
export struct EditContentDialog {
|
||||
editContentDialogCtl: CustomDialogController;
|
||||
editContentDialogCtl: CustomDialogController
|
||||
confirm: (excuteJs: string) => void
|
||||
@Consume('SelectedColor') selectedColor: string;
|
||||
@Consume('SelectedColor') selectedColor: string
|
||||
@State inSetValue: number = 20
|
||||
private circleColor: string
|
||||
private fontSize: number
|
||||
@ -318,86 +349,157 @@ export struct EditContentDialog {
|
||||
Column() {
|
||||
Row({ space: 70 }) {
|
||||
Button({ type: ButtonType.Normal, stateEffect: true }) {
|
||||
Image($r('app.media.action_bold')).height(24).width(24)
|
||||
Image($r('app.media.action_bold'))
|
||||
.height(24)
|
||||
.width(24)
|
||||
.onClick(() => {
|
||||
this.confirm("javascript:RE.setBold()")
|
||||
this.confirm("javascript:RICH_EDITOR.setBold()")
|
||||
})
|
||||
}.width(42).height(42).borderRadius(8).backgroundColor($r('app.color.color_ffffff'))
|
||||
}.width(42)
|
||||
.height(42)
|
||||
.borderRadius(8)
|
||||
.backgroundColor($r('app.color.color_ffffff'))
|
||||
|
||||
Button({ type: ButtonType.Normal, stateEffect: true }) {
|
||||
Image($r('app.media.format_italic')).height(24).width(24)
|
||||
Image($r('app.media.format_italic'))
|
||||
.height(24)
|
||||
.width(24)
|
||||
.onClick(() => {
|
||||
this.confirm("javascript:RE.setItalic()")
|
||||
this.confirm("javascript:RICH_EDITOR.setItalic()")
|
||||
})
|
||||
}.width(42).height(42).borderRadius(8).backgroundColor($r('app.color.color_ffffff'))
|
||||
}.width(42)
|
||||
.height(42)
|
||||
.borderRadius(8)
|
||||
.backgroundColor($r('app.color.color_ffffff'))
|
||||
|
||||
Button({ type: ButtonType.Normal, stateEffect: true }) {
|
||||
Image($r('app.media.underline')).height(24).width(24)
|
||||
Image($r('app.media.underline'))
|
||||
.height(24)
|
||||
.width(24)
|
||||
.onClick(() => {
|
||||
this.confirm("javascript:RE.setUnderline()")
|
||||
this.confirm("javascript:RICH_EDITOR.setUnderline()")
|
||||
})
|
||||
}.width(42).height(42).borderRadius(8).backgroundColor($r('app.color.color_ffffff'))
|
||||
}.width(42)
|
||||
.height(42)
|
||||
.borderRadius(8)
|
||||
.backgroundColor($r('app.color.color_ffffff'))
|
||||
|
||||
Button({ type: ButtonType.Normal, stateEffect: true }) {
|
||||
Image($r('app.media.right_justify')).height(24).width(24)
|
||||
Image($r('app.media.right_justify'))
|
||||
.height(24)
|
||||
.width(24)
|
||||
.onClick(() => {
|
||||
this.confirm("javascript:RE.setJustifyRight()")
|
||||
this.confirm("javascript:RICH_EDITOR.setJustifyRight()")
|
||||
})
|
||||
}.width(42).height(42).borderRadius(8).backgroundColor($r('app.color.color_ffffff'))
|
||||
}.width(42)
|
||||
.height(42)
|
||||
.borderRadius(8)
|
||||
.backgroundColor($r('app.color.color_ffffff'))
|
||||
|
||||
Button({ type: ButtonType.Normal, stateEffect: true }) {
|
||||
Image($r('app.media.mid_justify')).height(24).width(24)
|
||||
Image($r('app.media.mid_justify'))
|
||||
.height(24)
|
||||
.width(24)
|
||||
.onClick(() => {
|
||||
this.confirm("javascript:RE.setJustifyCenter()")
|
||||
this.confirm("javascript:RICH_EDITOR.setJustifyCenter()")
|
||||
})
|
||||
}.width(42).height(42).borderRadius(8).backgroundColor($r('app.color.color_ffffff'))
|
||||
}.width(42)
|
||||
.height(42)
|
||||
.borderRadius(8)
|
||||
.backgroundColor($r('app.color.color_ffffff'))
|
||||
|
||||
Button({ type: ButtonType.Normal, stateEffect: true }) {
|
||||
Image($r('app.media.left_justify')).height(24).width(24)
|
||||
Image($r('app.media.left_justify'))
|
||||
.height(24)
|
||||
.width(24)
|
||||
.onClick(() => {
|
||||
this.confirm("javascript:RE.setJustifyLeft()")
|
||||
this.confirm("javascript:RICH_EDITOR.setJustifyLeft()")
|
||||
})
|
||||
}.width(42).height(42).borderRadius(8).backgroundColor($r('app.color.color_ffffff'))
|
||||
}.width(42)
|
||||
.height(42)
|
||||
.borderRadius(8)
|
||||
.backgroundColor($r('app.color.color_ffffff'))
|
||||
}
|
||||
.alignItems(VerticalAlign.Bottom)
|
||||
.padding({ bottom: 2 })
|
||||
.height(71)
|
||||
|
||||
Divider().vertical(false).color($r("app.color.divider_color_e4e4e4"))
|
||||
Divider()
|
||||
.vertical(false)
|
||||
.color($r("app.color.divider_color_e4e4e4"))
|
||||
|
||||
Row({ space: 70 }) {
|
||||
Button({ type: ButtonType.Normal, stateEffect: true }) {
|
||||
Image($r('app.media.suojin')).height(24).width(24)
|
||||
Image($r('app.media.suojin'))
|
||||
.height(24)
|
||||
.width(24)
|
||||
.onClick(() => {
|
||||
this.confirm("javascript:RE.setIndent()")
|
||||
this.confirm("javascript:RICH_EDITOR.setIndent()")
|
||||
})
|
||||
}.width(42).height(42).borderRadius(8).backgroundColor($r('app.color.color_ffffff'))
|
||||
}.width(42)
|
||||
.height(42)
|
||||
.borderRadius(8)
|
||||
.backgroundColor($r('app.color.color_ffffff'))
|
||||
|
||||
Button({ type: ButtonType.Normal, stateEffect: true }) {
|
||||
Image($r('app.media.suojin_back')).height(24).width(24)
|
||||
Image($r('app.media.suojin_back'))
|
||||
.height(24)
|
||||
.width(24)
|
||||
.onClick(() => {
|
||||
this.confirm("javascript:RE.setOutdent()")
|
||||
this.confirm("javascript:RICH_EDITOR.setOutdent()")
|
||||
})
|
||||
}.width(42).height(42).borderRadius(8).backgroundColor($r('app.color.color_ffffff'))
|
||||
}.width(42)
|
||||
.height(42)
|
||||
.borderRadius(8)
|
||||
.backgroundColor($r('app.color.color_ffffff'))
|
||||
|
||||
Button({ type: ButtonType.Normal, stateEffect: true }) {
|
||||
Image($r("app.media.format_menulist_number")).height(24).width(24)
|
||||
Image($r("app.media.format_menulist_number"))
|
||||
.height(24)
|
||||
.width(24)
|
||||
.onClick(() => {
|
||||
this.confirm("javascript:RE.setNumbers()")
|
||||
this.confirm("javascript:RICH_EDITOR.setNumbers()")
|
||||
})
|
||||
}.width(42).height(42).borderRadius(8).backgroundColor($r('app.color.color_ffffff'))
|
||||
}.width(42)
|
||||
.height(42)
|
||||
.borderRadius(8)
|
||||
.backgroundColor($r('app.color.color_ffffff'))
|
||||
|
||||
Button({ type: ButtonType.Normal, stateEffect: true }) {
|
||||
Image($r("app.media.format_menulist_alphabet")).height(24).width(24)
|
||||
Image($r("app.media.format_menulist_alphabet"))
|
||||
.height(24)
|
||||
.width(24)
|
||||
.onClick(() => {
|
||||
this.confirm("javascript:RE.setABC()")
|
||||
this.confirm("javascript:RICH_EDITOR.setABC()")
|
||||
})
|
||||
}.width(42).height(42).borderRadius(8).backgroundColor($r('app.color.color_ffffff'))
|
||||
}.width(42)
|
||||
.height(42)
|
||||
.borderRadius(8)
|
||||
.backgroundColor($r('app.color.color_ffffff'))
|
||||
|
||||
Button({ type: ButtonType.Normal, stateEffect: true }) {
|
||||
Image($r('app.media.format_menubullte2')).height(24).width(24)
|
||||
Image($r('app.media.format_menubullte2'))
|
||||
.height(24)
|
||||
.width(24)
|
||||
.onClick(() => {
|
||||
this.confirm("javascript:RE.setBullets()")
|
||||
this.confirm("javascript:RICH_EDITOR.setBullets()")
|
||||
})
|
||||
}.width(42).height(42).borderRadius(8).backgroundColor($r('app.color.color_ffffff'))
|
||||
}.width(42)
|
||||
.height(42)
|
||||
.borderRadius(8)
|
||||
.backgroundColor($r('app.color.color_ffffff'))
|
||||
|
||||
Button({ type: ButtonType.Normal, stateEffect: true }) {
|
||||
Image($r('app.media.format_menubullte1')).height(24).width(24)
|
||||
Image($r('app.media.format_menubullte1'))
|
||||
.height(24)
|
||||
.width(24)
|
||||
.onClick(() => {
|
||||
this.confirm("javascript:RE.setSquare()")
|
||||
this.confirm("javascript:RICH_EDITOR.setSquare()")
|
||||
})
|
||||
}.width(42).height(42).borderRadius(8).backgroundColor($r('app.color.color_ffffff'))
|
||||
}.width(42)
|
||||
.height(42)
|
||||
.borderRadius(8)
|
||||
.backgroundColor($r('app.color.color_ffffff'))
|
||||
}
|
||||
.alignItems(VerticalAlign.Top)
|
||||
.padding({ top: 2 })
|
||||
@ -407,26 +509,36 @@ export struct EditContentDialog {
|
||||
.padding({ left: 24, right: 24 })
|
||||
.height(128)
|
||||
|
||||
Divider().vertical(true).height(128).color($r("app.color.divider_color_e4e4e4")).margin({top:4,bottom:4})
|
||||
Divider()
|
||||
.vertical(true)
|
||||
.height(128)
|
||||
.color($r("app.color.divider_color_e4e4e4"))
|
||||
.margin({ top: 4, bottom: 4 })
|
||||
|
||||
Column() {
|
||||
Flex({ direction: FlexDirection.Row, wrap: FlexWrap.Wrap, justifyContent: FlexAlign.End }) {
|
||||
Image($r('app.media.cross')).height(16).width(16).margin({top:8})
|
||||
Image($r('app.media.cross'))
|
||||
.height(16)
|
||||
.width(16)
|
||||
.margin({ top: 8 })
|
||||
.onClick(() => {
|
||||
this.editContentDialogCtl.close()
|
||||
})
|
||||
}
|
||||
.height(36)
|
||||
|
||||
Row() {
|
||||
Flex({ wrap: FlexWrap.NoWrap, justifyContent: FlexAlign.SpaceBetween }) {
|
||||
ForEach(fontColorArray, (colorStr: string) => {
|
||||
Stack({ alignContent: Alignment.Center }) {
|
||||
Circle({ width: 24, height: 24 }).fill(colorStr)
|
||||
Circle({ width: 12, height: 12 }).fill($r("app.color.color_ffffff"))
|
||||
Circle({ width: 24, height: 24 })
|
||||
.fill(colorStr)
|
||||
Circle({ width: 12, height: 12 })
|
||||
.fill($r("app.color.color_ffffff"))
|
||||
.visibility(colorStr == this.selectedColor ? Visibility.Visible : Visibility.None)
|
||||
}.onClick(() => {
|
||||
this.selectedColor = colorStr
|
||||
this.confirm("javascript:RE.setTextColor('" + this.selectedColor + "')")
|
||||
this.confirm("javascript:RICH_EDITOR.setTextColor('" + this.selectedColor + "')")
|
||||
})
|
||||
}, colorStr => colorStr)
|
||||
}.padding({ bottom: 11 })
|
||||
@ -434,10 +546,15 @@ export struct EditContentDialog {
|
||||
.alignItems(VerticalAlign.Top)
|
||||
.height(35)
|
||||
|
||||
Divider().vertical(false).color($r("app.color.divider_color_e4e4e4"))
|
||||
Divider()
|
||||
.vertical(false)
|
||||
.color($r("app.color.divider_color_e4e4e4"))
|
||||
|
||||
Row({ space: 15 }) {
|
||||
Image($r('app.media.font_small')).height(24).width(24).margin({top:8})
|
||||
Image($r('app.media.font_small'))
|
||||
.height(24)
|
||||
.width(24)
|
||||
.margin({ top: 8 })
|
||||
Slider({
|
||||
value: this.inSetValue,
|
||||
min: 0,
|
||||
@ -453,11 +570,14 @@ export struct EditContentDialog {
|
||||
.onChange((value: number, mode: SliderChangeMode) => {
|
||||
this.inSetValue = value
|
||||
this.fontSize = value + 20
|
||||
this.confirm("javascript:RE.execFontSize('" + this.fontSize+"')")
|
||||
this.confirm("javascript:RICH_EDITOR.execFontSize('" + this.fontSize + "')")
|
||||
console.info('value:' + value + 'mode:' + mode.toString())
|
||||
})
|
||||
.width('88%')
|
||||
Image($r('app.media.font_large')).height(24).width(24).margin({top:7})
|
||||
Image($r('app.media.font_large'))
|
||||
.height(24)
|
||||
.width(24)
|
||||
.margin({ top: 7 })
|
||||
}
|
||||
.alignItems(VerticalAlign.Top)
|
||||
.padding({ top: 5 })
|
||||
@ -476,13 +596,16 @@ export struct EditContentDialog {
|
||||
|
||||
@CustomDialog
|
||||
export struct EditTitleDialog {
|
||||
editTitleDialog: CustomDialogController;
|
||||
editTitleDialog: CustomDialogController
|
||||
confirm: (newTitle: string) => void
|
||||
@State inputName: string = "";
|
||||
@State inputName: string = ""
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Text($r("app.string.editNoteTitle")).fontSize(20).height(56).margin({ left: 24 })
|
||||
Text($r("app.string.editNoteTitle"))
|
||||
.fontSize(20)
|
||||
.height(56)
|
||||
.margin({ left: 24 })
|
||||
|
||||
// title input
|
||||
Flex({ wrap: FlexWrap.NoWrap, justifyContent: FlexAlign.SpaceBetween }) {
|
||||
@ -508,7 +631,11 @@ export struct EditTitleDialog {
|
||||
.onClick(() => {
|
||||
this.editTitleDialog.close()
|
||||
})
|
||||
Divider().vertical(true).height(15).strokeWidth(1).color($r("app.color.divider_color_e4e4e4"))
|
||||
Divider()
|
||||
.vertical(true)
|
||||
.height(15)
|
||||
.strokeWidth(1)
|
||||
.color($r("app.color.divider_color_e4e4e4"))
|
||||
Text($r("app.string.save"))
|
||||
.opacity((this.inputName == "") ? 0.4 : 1)
|
||||
.enabled((this.inputName == "") ? false : true)
|
||||
@ -520,7 +647,8 @@ export struct EditTitleDialog {
|
||||
this.editTitleDialog.close()
|
||||
this.confirm(this.inputName)
|
||||
})
|
||||
}.width('100%').margin({ top: 21, bottom: 25 })
|
||||
}.width('100%')
|
||||
.margin({ top: 21, bottom: 25 })
|
||||
}
|
||||
.width(336)
|
||||
.borderRadius(36)
|
||||
@ -529,3 +657,148 @@ export struct EditTitleDialog {
|
||||
.margin({ bottom: 16, left: 12, right: 12 })
|
||||
}
|
||||
}
|
||||
|
||||
@CustomDialog
|
||||
export struct EditContentDialogPortrait {
|
||||
editContentDialogCtl: CustomDialogController;
|
||||
confirm: (excuteJs: string) => void
|
||||
@Consume('SelectedColor') selectedColor: string;
|
||||
@State inSetValue: number = 20
|
||||
private circleColor: string
|
||||
private fontSize: number
|
||||
|
||||
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Flex({ direction: FlexDirection.Row, wrap: FlexWrap.NoWrap,
|
||||
justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
|
||||
Text($r("app.string.style")).margin({ top: 8 })
|
||||
.fontSize(14).fontColor($r("app.color.font_stylecolor_AD182431"))
|
||||
|
||||
Image($r('app.media.cross')).height(16).width(16).margin({ top: 8 })
|
||||
.onClick(() => {
|
||||
this.editContentDialogCtl.close()
|
||||
})
|
||||
}
|
||||
.height(48)
|
||||
|
||||
|
||||
Row({ space: 34 }) {
|
||||
Image($r('app.media.action_bold')).height(24).width(24)
|
||||
.onClick(() => {
|
||||
this.confirm("javascript:RICH_EDITOR.setBold()")
|
||||
})
|
||||
Image($r('app.media.format_italic')).height(24).width(24)
|
||||
.onClick(() => {
|
||||
this.confirm("javascript:RICH_EDITOR.setItalic()")
|
||||
})
|
||||
Image($r('app.media.underline')).height(24).width(24)
|
||||
.onClick(() => {
|
||||
this.confirm("javascript:RICH_EDITOR.setUnderline()")
|
||||
})
|
||||
Image($r('app.media.right_justify')).height(24).width(24)
|
||||
.onClick(() => {
|
||||
this.confirm("javascript:RICH_EDITOR.setJustifyRight()")
|
||||
})
|
||||
Image($r('app.media.mid_justify')).height(24).width(24)
|
||||
.onClick(() => {
|
||||
this.confirm("javascript:RICH_EDITOR.setJustifyCenter()")
|
||||
})
|
||||
Image($r('app.media.left_justify')).height(24).width(24)
|
||||
.onClick(() => {
|
||||
this.confirm("javascript:RICH_EDITOR.setJustifyLeft()")
|
||||
})
|
||||
}
|
||||
.height(48)
|
||||
|
||||
Divider().vertical(false).color($r("app.color.divider_color_e4e4e4"))
|
||||
|
||||
Row({ space: 34 }) {
|
||||
|
||||
Image($r('app.media.suojin')).height(24).width(24)
|
||||
.onClick(() => {
|
||||
this.confirm("javascript:RICH_EDITOR.setIndent()")
|
||||
})
|
||||
|
||||
Image($r('app.media.suojin_back')).height(24).width(24)
|
||||
.onClick(() => {
|
||||
this.confirm("javascript:RICH_EDITOR.setOutdent()")
|
||||
})
|
||||
|
||||
Image($r("app.media.format_menulist_number")).height(24).width(24)
|
||||
.onClick(() => {
|
||||
this.confirm("javascript:RICH_EDITOR.setNumbers()")
|
||||
})
|
||||
|
||||
Image($r("app.media.format_menulist_alphabet")).height(24).width(24)
|
||||
.onClick(() => {
|
||||
this.confirm("javascript:RICH_EDITOR.setABC()")
|
||||
})
|
||||
|
||||
Image($r('app.media.format_menubullte2')).height(24).width(24)
|
||||
.onClick(() => {
|
||||
this.confirm("javascript:RICH_EDITOR.setBullets()")
|
||||
})
|
||||
|
||||
Image($r('app.media.format_menubullte1')).height(24).width(24)
|
||||
.onClick(() => {
|
||||
this.confirm("javascript:RICH_EDITOR.setSquare()")
|
||||
})
|
||||
}
|
||||
.height(48)
|
||||
|
||||
Divider().vertical(false).color($r("app.color.divider_color_e4e4e4"))
|
||||
|
||||
Row() {
|
||||
Flex({ wrap: FlexWrap.NoWrap, justifyContent: FlexAlign.SpaceBetween }) {
|
||||
ForEach(fontColorArray, (colorStr: string) => {
|
||||
Stack({ alignContent: Alignment.Center }) {
|
||||
Circle({ width: 24, height: 24 }).fill(colorStr)
|
||||
Circle({ width: 12, height: 12 }).fill($r("app.color.color_ffffff"))
|
||||
.visibility(colorStr == this.selectedColor ? Visibility.Visible : Visibility.None)
|
||||
}.onClick(() => {
|
||||
this.selectedColor = colorStr
|
||||
this.confirm("javascript:RICH_EDITOR.setTextColor('" + this.selectedColor + "')")
|
||||
})
|
||||
}, colorStr => colorStr)
|
||||
}
|
||||
}
|
||||
.height(48)
|
||||
|
||||
Divider().vertical(false).color($r("app.color.divider_color_e4e4e4"))
|
||||
|
||||
Row({ space: 10 }) {
|
||||
Image($r('app.media.font_small')).height(24).width(24).margin({ top: 8 })
|
||||
Slider({
|
||||
value: this.inSetValue,
|
||||
min: 0,
|
||||
max: 60,
|
||||
step: 10,
|
||||
style: SliderStyle.InSet
|
||||
})
|
||||
.blockColor($r("app.color.color_ffffff"))
|
||||
.trackColor($r("app.color.divider_color_e4e4e4"))
|
||||
.selectedColor($r("app.color.text_color_f86d05"))
|
||||
.showSteps(false)
|
||||
.showTips(false)
|
||||
.onChange((value: number, mode: SliderChangeMode) => {
|
||||
this.inSetValue = value
|
||||
this.fontSize = value + 20
|
||||
this.confirm("javascript:RICH_EDITOR.execFontSize('" + this.fontSize + "')")
|
||||
console.info('value:' + value + 'mode:' + mode.toString())
|
||||
})
|
||||
.width('79%')
|
||||
Image($r('app.media.font_large')).height(24).width(24).margin({ top: 7 })
|
||||
}
|
||||
.alignItems(VerticalAlign.Top)
|
||||
.padding({ top: 5 })
|
||||
.height(72)
|
||||
}
|
||||
.width(360)
|
||||
.height(266)
|
||||
.backgroundColor($r("app.color.color_ffffff"))
|
||||
.borderRadius(36)
|
||||
.padding({ left: 24, right: 24 })
|
||||
}
|
||||
}
|
@ -15,13 +15,13 @@
|
||||
|
||||
import FolderData from '../../../../../../common/utils/src/main/ets/default/model/databaseModel/FolderData.ets'
|
||||
import NoteData from '../../../../../../common/utils/src/main/ets/default/model/databaseModel/NoteData.ets'
|
||||
import {SysDefFolderUuid, TableName, FolderType, FolderTableColumn, NoteTableColumn, Delete, DeleteFileType
|
||||
} from '../../../../../../common/utils/src/main/ets/default/model/databaseModel/EnumData.ets'
|
||||
import {SysDefFolderUuid, TableName, FolderType, FolderTableColumn, NoteTableColumn, Delete, DeleteFileType} from '../../../../../../common/utils/src/main/ets/default/model/databaseModel/EnumData.ets'
|
||||
import {NewOrEditFolderDialog, DeleteDialog} from './CusDialogComp.ets'
|
||||
import StyleConstants from '../../../../../../common/utils/src/main/ets/default/constants/StyleConstants.ets'
|
||||
import RdbStoreUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/RdbStoreUtil.ets'
|
||||
import FolderUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/FolderUtil.ets'
|
||||
import NoteUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/NoteUtil.ets'
|
||||
import LogUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'
|
||||
|
||||
// Folder list component
|
||||
@Component
|
||||
@ -30,12 +30,15 @@ export struct FolderListComp {
|
||||
@Consume('SectionStatus') sectionStatus: number
|
||||
@Consume('ExpandStatus') expandStatus: boolean // 笔记本折叠展开状态
|
||||
controllerShow: WebController
|
||||
TAG = "FolderListComp"
|
||||
|
||||
build() {
|
||||
Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
|
||||
Column() {
|
||||
Column() {
|
||||
Image($r("app.media.suojin")).height(24).width(24)
|
||||
Image($r("app.media.suojin"))
|
||||
.height(24)
|
||||
.width(24)
|
||||
.onClick(() => {
|
||||
if (this.sectionStatus == 1) {
|
||||
this.expandStatus = !this.expandStatus
|
||||
@ -48,7 +51,9 @@ export struct FolderListComp {
|
||||
}
|
||||
})
|
||||
}.alignItems(HorizontalAlign.Start)
|
||||
.width("100%").margin({ top: 28 }).padding({ left: 24 })
|
||||
.width("100%")
|
||||
.margin({ top: 28 })
|
||||
.padding({ left: 24 })
|
||||
|
||||
NoteAndCreateComp()
|
||||
// center
|
||||
@ -62,34 +67,47 @@ export struct FolderListComp {
|
||||
}
|
||||
}, folderItem => folderItem.name.toString())
|
||||
}
|
||||
}.width('100%').padding({ left: 12, right: 12 }).height(7 * 56) // 列表最多显示7个 每个的高度为56
|
||||
}.width('100%')
|
||||
.padding({ left: 12, right: 12 })
|
||||
.height(7 * 56) // 列表最多显示7个 每个的高度为56
|
||||
}
|
||||
|
||||
Column() {
|
||||
FolderItemComp({
|
||||
folderItem: FolderUtil.getFolderData(AppStorage.Get('AllFolderArray'), SysDefFolderUuid.MyFavorites),controllerShow: this.controllerShow
|
||||
folderItem: FolderUtil.getFolderData(AppStorage.Get('AllFolderArray'), SysDefFolderUuid.MyFavorites),
|
||||
controllerShow: this.controllerShow
|
||||
})
|
||||
FolderItemComp({
|
||||
folderItem: FolderUtil.getFolderData(AppStorage.Get('AllFolderArray'), SysDefFolderUuid.RecentDeletes),controllerShow: this.controllerShow
|
||||
folderItem: FolderUtil.getFolderData(AppStorage.Get('AllFolderArray'), SysDefFolderUuid.RecentDeletes),
|
||||
controllerShow: this.controllerShow
|
||||
})
|
||||
}.margin({ bottom: 48 }).width("100%").padding({ left: 12, right: 12 })
|
||||
}.margin({ bottom: 48 })
|
||||
.width("100%")
|
||||
.padding({ left: 12, right: 12 })
|
||||
}
|
||||
}
|
||||
|
||||
aboutToAppear(): void{
|
||||
LogUtil.info(this.TAG, "aboutToAppear")
|
||||
}
|
||||
|
||||
aboutToDisappear(): void{
|
||||
LogUtil.info(this.TAG, "aboutToDisappear")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Component
|
||||
export struct NoteAndCreateComp {
|
||||
@StorageLink('AllFolderArray') AllFolderArray: FolderData[] = AppStorage.Link('AllFolderArray')
|
||||
@Consume('SelectedColor') selectedColor: string;
|
||||
@Consume('SelectedColor') selectedColor: string
|
||||
@Consume('PortraitModel') portraitModel: boolean
|
||||
|
||||
folderCreateDialogCtl: CustomDialogController = new CustomDialogController({
|
||||
builder: NewOrEditFolderDialog({ confirm: this.onCreateConfirm.bind(this), dialogType: 0 }),
|
||||
alignment: DialogAlignment.Center,
|
||||
autoCancel: false,
|
||||
customStyle: true,
|
||||
})
|
||||
|
||||
folderCreateDialogCtlBottom: CustomDialogController = new CustomDialogController({
|
||||
builder: NewOrEditFolderDialog({ confirm: this.onCreateConfirm.bind(this), dialogType: 0 }),
|
||||
alignment: DialogAlignment.Bottom,
|
||||
@ -125,7 +143,10 @@ export struct NoteAndCreateComp {
|
||||
}
|
||||
}).padding({ right: 0 })
|
||||
}.width(50)
|
||||
}.width("100%").margin({ top: 8 }).padding({ left: 24 }).height(56)
|
||||
}.width("100%")
|
||||
.margin({ top: 8 })
|
||||
.padding({ left: 24 })
|
||||
.height(56)
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,13 +157,12 @@ struct FolderItemComp {
|
||||
@StorageLink('AllFolderArray') AllFolderArray: FolderData[] = []
|
||||
@StorageLink('CheckedNoteArray') CheckedNoteArray: NoteData[] = []
|
||||
@Consume('SelectedFolderData') selectedFolderData: FolderData
|
||||
@Consume('SelectedNoteData') selectedNoteData: NoteData;
|
||||
@Consume('SelectedNoteData') selectedNoteData: NoteData
|
||||
@Consume('RefreshFlag') refreshFlag: number
|
||||
@Consume('Longpress') longpress: boolean
|
||||
@Consume('SelectedColor') selectedColor: string;
|
||||
@Consume('SelectedColor') selectedColor: string
|
||||
@Consume('PortraitModel') portraitModel: boolean
|
||||
controllerShow: WebController
|
||||
|
||||
private isLongPress: boolean = false
|
||||
TAG = "FolderListComp"
|
||||
// Folder Edit Dialog
|
||||
@ -211,6 +231,15 @@ struct FolderItemComp {
|
||||
let predicates_folder = RdbStoreUtil.getRdbPredicates(TableName.FolderTable)
|
||||
predicates_folder.equalTo(FolderTableColumn.Uuid, this.folderItem.uuid)
|
||||
RdbStoreUtil.delete(predicates_folder, null)
|
||||
// update selectedFolderData and selectedNoteData
|
||||
this.selectedFolderData = FolderUtil.getFolderData(this.AllFolderArray, SysDefFolderUuid.AllNotes)
|
||||
this.selectedNoteData = NoteUtil.getFirstNoteData(this.AllNoteArray, SysDefFolderUuid.AllNotes)
|
||||
// save continue data
|
||||
let continueFolder: string = JSON.stringify(this.selectedFolderData.toFolderObject())
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
|
||||
AppStorage.SetOrCreate<string>('ContinueFolder', continueFolder)
|
||||
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
|
||||
console.log("onDeleteConfirm, set continue folder and note success")
|
||||
}
|
||||
}
|
||||
// Folder Create Dialog
|
||||
@ -238,33 +267,46 @@ struct FolderItemComp {
|
||||
@Builder menuBuilder() {
|
||||
Column({ space: 1 }) {
|
||||
Text($r("app.string.editFolder"))
|
||||
.width(124).height(48).padding({top:13, bottom: 13})
|
||||
.fontSize(16).fontColor($r("app.color.folder_color_182431"))
|
||||
.width(124)
|
||||
.height(48)
|
||||
.padding({ top: 13, bottom: 13 })
|
||||
.fontSize(16)
|
||||
.fontColor($r("app.color.folder_color_182431"))
|
||||
.onClick(() => {
|
||||
this.selectedColor = this.folderItem.color;
|
||||
this.selectedColor = this.folderItem.color
|
||||
if (this.portraitModel) {
|
||||
this.folderEditDialogCtlBottom.open()
|
||||
} else {
|
||||
this.folderEditDialogCtl.open()
|
||||
}
|
||||
ContextMenu.close();
|
||||
ContextMenu.close()
|
||||
})
|
||||
Divider().color($r("app.color.divider_color_e4e4e4")).strokeWidth(1)
|
||||
Divider()
|
||||
.color($r("app.color.divider_color_e4e4e4"))
|
||||
.strokeWidth(1)
|
||||
Text($r("app.string.deleteFolder"))
|
||||
.width(124).height(48).padding({top:13, bottom: 14})
|
||||
.fontSize(16).fontColor($r("app.color.folder_color_182431"))
|
||||
.width(124)
|
||||
.height(48)
|
||||
.padding({ top: 13, bottom: 14 })
|
||||
.fontSize(16)
|
||||
.fontColor($r("app.color.folder_color_182431"))
|
||||
.onClick(() => {
|
||||
if (this.portraitModel) {
|
||||
this.folderDeleteDialogCtlBottom.open()
|
||||
} else {
|
||||
this.folderDeleteDialogCtl.open()
|
||||
}
|
||||
ContextMenu.close();
|
||||
ContextMenu.close()
|
||||
})
|
||||
Divider().color($r("app.color.divider_color_e4e4e4")).strokeWidth(1)
|
||||
Divider()
|
||||
.color($r("app.color.divider_color_e4e4e4"))
|
||||
.strokeWidth(1)
|
||||
Text($r("app.string.createFolder"))
|
||||
.width(124).height(48).padding({top:13, bottom: 15})
|
||||
.fontSize(16).fontColor($r("app.color.folder_color_182431"))
|
||||
.width(124)
|
||||
.height(48)
|
||||
.padding({ top: 13, bottom: 15 })
|
||||
.fontSize(16)
|
||||
.fontColor($r("app.color.folder_color_182431"))
|
||||
.onClick(() => {
|
||||
this.selectedColor = "#e84026" // 新建的时候选中第一个颜色
|
||||
if (this.portraitModel) {
|
||||
@ -272,9 +314,14 @@ struct FolderItemComp {
|
||||
} else {
|
||||
this.folderCreateDialogCtl.open()
|
||||
}
|
||||
ContextMenu.close();
|
||||
ContextMenu.close()
|
||||
})
|
||||
}.width(156).height(154).padding({top: 4, bottom: 4, left: 16, right: 16}).borderRadius(16).backgroundColor(Color.White)
|
||||
}
|
||||
.width(156)
|
||||
.height(154)
|
||||
.padding({ top: 4, bottom: 4, left: 16, right: 16 })
|
||||
.borderRadius(16)
|
||||
.backgroundColor(Color.White)
|
||||
.visibility(this.folderItem.folder_type == FolderType.CusDef ? Visibility.Visible : Visibility.None)
|
||||
}
|
||||
|
||||
@ -295,7 +342,8 @@ struct FolderItemComp {
|
||||
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
||||
.flexShrink(1)
|
||||
.fontColor(FolderUtil.getFolderTextColor(this.selectedFolderData.uuid == this.folderItem.uuid))
|
||||
Text(this.refreshFlag.toString()).visibility(Visibility.None) // 用于强制刷新使用
|
||||
Text(this.refreshFlag.toString())
|
||||
.visibility(Visibility.None) // 用于强制刷新使用
|
||||
}.width(118)
|
||||
|
||||
Text(FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.folderItem.uuid).toString())
|
||||
@ -318,16 +366,10 @@ struct FolderItemComp {
|
||||
this.selectedFolderData = this.folderItem
|
||||
this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), this.folderItem.uuid)
|
||||
// 刷新web界面
|
||||
this.controllerShow.runJavaScript({script:"RE.setHtml('" + this.selectedNoteData.content_text + "')"})
|
||||
// 迁移
|
||||
console.log("FolderItemComp, set continue folder and note")
|
||||
|
||||
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')" })
|
||||
// save continue data
|
||||
let continueFolder: string = JSON.stringify(this.selectedFolderData.toFolderObject())
|
||||
console.log("FolderItemComp, continueFolder : " + continueFolder)
|
||||
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
|
||||
console.log("FolderItemComp, continueNote : " + continueNote)
|
||||
|
||||
AppStorage.SetOrCreate<string>('ContinueFolder', continueFolder)
|
||||
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
|
||||
AppStorage.SetOrCreate('ContinueSection', 3)
|
||||
|
@ -17,14 +17,13 @@ import DateUtil from '../../../../../../common/utils/src/main/ets/default/baseUt
|
||||
import RdbStoreUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/RdbStoreUtil.ets'
|
||||
import FolderData from '../../../../../../common/utils/src/main/ets/default/model/databaseModel/FolderData.ets'
|
||||
import NoteData from '../../../../../../common/utils/src/main/ets/default/model/databaseModel/NoteData.ets'
|
||||
import {TableName, NoteTableColumn, SysDefFolderUuid, Favorite, Delete
|
||||
} from '../../../../../../common/utils/src/main/ets/default/model/databaseModel/EnumData.ets'
|
||||
import {TableName, NoteTableColumn, SysDefFolderUuid, Favorite, Delete} from '../../../../../../common/utils/src/main/ets/default/model/databaseModel/EnumData.ets'
|
||||
import StyleConstants from '../../../../../../common/utils/src/main/ets/default/constants/StyleConstants.ets'
|
||||
import {EditContentDialog, DeleteDialog, EditTitleDialog} from './CusDialogComp.ets'
|
||||
import FolderUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/FolderUtil.ets'
|
||||
import NoteUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/NoteUtil.ets'
|
||||
import prompt from '@system.prompt'
|
||||
import featureAbility from '@ohos.ability.featureAbility';
|
||||
import featureAbility from '@ohos.ability.featureAbility'
|
||||
import LogUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'
|
||||
|
||||
const TAG = "NoteContentComp"
|
||||
@ -32,7 +31,7 @@ const TAG = "NoteContentComp"
|
||||
// Note content component
|
||||
@Component
|
||||
export struct NoteContentComp {
|
||||
@Consume('SelectedNoteData') selectedNoteData: NoteData;
|
||||
@Consume('SelectedNoteData') selectedNoteData: NoteData
|
||||
@StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray')
|
||||
@Consume('SelectedFolderData') selectedFolderData: FolderData
|
||||
@Consume('RefreshFlag') refreshFlag: number
|
||||
@ -41,9 +40,8 @@ export struct NoteContentComp {
|
||||
@Consume('LastSectionStatus') lastSectionStatus: number
|
||||
controllerShow: WebController
|
||||
private editContentFlag = false
|
||||
@State uri1 : string = "";
|
||||
@State uri1: string = ""
|
||||
private context = getContext(this)
|
||||
|
||||
noteContent = {
|
||||
callbackhtml: (html) => {
|
||||
LogUtil.info(TAG, 'html content is:' + html)
|
||||
@ -54,9 +52,33 @@ export struct NoteContentComp {
|
||||
predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid)
|
||||
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null)
|
||||
LogUtil.info(TAG, 'update note success:' + this.selectedNoteData)
|
||||
// save continue data
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
|
||||
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
|
||||
console.log("callbackhtml, set continue note success")
|
||||
return "AceString"
|
||||
},
|
||||
|
||||
callbackhtmlSave: (html) => {
|
||||
LogUtil.info(TAG, 'html content is:' + html)
|
||||
LogUtil.info(TAG, 'note uuid is:' + this.selectedNoteData.uuid)
|
||||
this.selectedNoteData.content_text = html
|
||||
this.selectedNoteData.modified_time = new Date().getTime()
|
||||
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
|
||||
predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid)
|
||||
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null)
|
||||
LogUtil.info(TAG, 'update note success:' + this.selectedNoteData)
|
||||
// save continue data
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
|
||||
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
|
||||
console.log("callbackhtml, set continue note success")
|
||||
// 删除空白笔记
|
||||
NoteUtil.deleteEmptyNote(this.selectedNoteData,this.AllNoteArray,this.controllerShow)
|
||||
return "AceString";
|
||||
if(NoteUtil.deleteEmptyNote(this.selectedNoteData,this.AllNoteArray,this.controllerShow)) {
|
||||
this.selectedNoteData = this.AllNoteArray[0]
|
||||
LogUtil.info(TAG, "selectedNoteData note:" + this.selectedNoteData.uuid)
|
||||
this.controllerShow.runJavaScript({script:"RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')"})
|
||||
}
|
||||
return "AceString"
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,25 +102,26 @@ export struct NoteContentComp {
|
||||
this.controllerShow.registerJavaScriptProxy({
|
||||
obj: this.noteContent,
|
||||
name: "callBackToApp", // html--> name.method
|
||||
methodList: ["callbackhtml"],
|
||||
});
|
||||
methodList: ["callbackhtml","callbackhtmlSave"],
|
||||
})
|
||||
LogUtil.info(TAG, "finish register")
|
||||
this.controllerShow.refresh()
|
||||
this.editContentFlag = true
|
||||
}
|
||||
LogUtil.info(TAG, "finish loadurl")
|
||||
console.log('onPageEnd:' + e.url)
|
||||
this.controllerShow.runJavaScript({script:"RE.setHtml('" + this.selectedNoteData.content_text + "')"})
|
||||
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')" })
|
||||
// 初次加载为为小屏预览模式
|
||||
if (this.sectionStatus != 1) {
|
||||
this.controllerShow.runJavaScript({script:"RE.setInputEnabled(false)"})
|
||||
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setInputEnabled(false)" })
|
||||
}
|
||||
})
|
||||
.zoomAccess(false)
|
||||
.height(450)
|
||||
.width('100%')
|
||||
}
|
||||
.margin({ top: 16 }).width(StyleConstants.PERCENTAGE_100)
|
||||
.margin({ top: 16 })
|
||||
.width(StyleConstants.PERCENTAGE_100)
|
||||
.opacity(this.selectedNoteData.is_deleted == Delete.Yes ? 0.4 : 1)
|
||||
.enabled(this.selectedNoteData.is_deleted == Delete.Yes ? false : true)
|
||||
.onClick(() => {
|
||||
@ -106,8 +129,11 @@ export struct NoteContentComp {
|
||||
if (this.sectionStatus != 1) {
|
||||
this.lastSectionStatus = this.sectionStatus
|
||||
this.sectionStatus = 1
|
||||
this.controllerShow.runJavaScript({script:"RE.setInputEnabled(true)"})
|
||||
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setInputEnabled(true)" })
|
||||
this.editModel = !this.editModel
|
||||
// save continue data
|
||||
AppStorage.SetOrCreate<number>('ContinueSection', this.sectionStatus)
|
||||
console.log("NoteContentComp, set continue section success")
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -120,16 +146,24 @@ export struct NoteContentComp {
|
||||
.height(StyleConstants.PERCENTAGE_100)
|
||||
.width(StyleConstants.PERCENTAGE_100)
|
||||
}
|
||||
|
||||
aboutToAppear(): void{
|
||||
LogUtil.info(TAG, "aboutToAppear")
|
||||
}
|
||||
|
||||
aboutToDisappear(): void{
|
||||
LogUtil.info(TAG, "aboutToDisappear")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Component
|
||||
export struct NoteContentOverViewComp {
|
||||
@Consume('SelectedNoteData') selectedNoteData: NoteData;
|
||||
@Consume('SelectedNoteData') selectedNoteData: NoteData
|
||||
@StorageLink('AllFolderArray') AllFolderArray: FolderData[] = []
|
||||
@StorageLink('CheckedNoteArray') CheckedNoteArray: NoteData[] = []
|
||||
@Consume('EditModel') editModel: boolean
|
||||
@Consume('SectionStatus') sectionStatus: number
|
||||
|
||||
editTitleDialogCtl: CustomDialogController = new CustomDialogController({
|
||||
builder: EditTitleDialog({ confirm: this.confirm.bind(this), dialogType: 0 }),
|
||||
alignment: DialogAlignment.Center,
|
||||
@ -174,11 +208,16 @@ export struct NoteContentOverViewComp {
|
||||
this.editModel = true
|
||||
this.sectionStatus = 1
|
||||
this.editTitleDialogCtl.open()
|
||||
// save continue data
|
||||
AppStorage.SetOrCreate<number>('ContinueSection', this.sectionStatus)
|
||||
console.log("NoteContentOverViewComp, set continue section success")
|
||||
})
|
||||
}.height(40).width(StyleConstants.PERCENTAGE_100)
|
||||
}.height(40)
|
||||
.width(StyleConstants.PERCENTAGE_100)
|
||||
|
||||
Row() {
|
||||
Text(DateUtil.formateDateForNoteContent(new Date(this.selectedNoteData.modified_time))).fontSize(12)
|
||||
Text(DateUtil.formateDateForNoteContent(new Date(this.selectedNoteData.modified_time)))
|
||||
.fontSize(12)
|
||||
.padding({ top: 4, bottom: 4 })
|
||||
Row() {
|
||||
Text(FolderUtil.getFolderText(FolderUtil.getFolderData(AppStorage.Get('AllFolderArray'), this.selectedNoteData.folder_uuid)))
|
||||
@ -202,7 +241,7 @@ export struct NoteContentOverViewComp {
|
||||
|
||||
@Component
|
||||
export struct ToolBarComp {
|
||||
@Consume('SelectedNoteData') selectedNoteData: NoteData;
|
||||
@Consume('SelectedNoteData') selectedNoteData: NoteData
|
||||
@Consume('RefreshFlag') refreshFlag: number
|
||||
@Consume('SectionStatus') sectionStatus: number
|
||||
@Consume('LastSectionStatus') lastSectionStatus: number
|
||||
@ -245,12 +284,10 @@ export struct ToolBarComp {
|
||||
}
|
||||
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
|
||||
this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid)
|
||||
this.controllerShow.runJavaScript({script:"RE.setHtml('" + this.selectedNoteData.content_text + "')"})
|
||||
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')" })
|
||||
this.chooseNote = false
|
||||
// 迁移
|
||||
console.log("ToolBarComp, onDeleteConfirm, set continue note")
|
||||
// save continue data
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
|
||||
console.log("ToolBarComp, onDeleteConfirm, continueNote : " + continueNote)
|
||||
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
|
||||
console.log("ToolBarComp, onDeleteConfirm, set continue note success")
|
||||
}
|
||||
@ -267,30 +304,33 @@ export struct ToolBarComp {
|
||||
this.controllerShow.runJavaScript({ script: excuteJs })
|
||||
}
|
||||
|
||||
|
||||
build() {
|
||||
Flex({ direction: FlexDirection.Row, wrap: FlexWrap.NoWrap,
|
||||
justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
|
||||
if (this.portraitModel == true) {
|
||||
Image($r('app.media.back')).height(24).width(24)
|
||||
Image($r('app.media.back'))
|
||||
.height(24)
|
||||
.width(24)
|
||||
.onClick(() => {
|
||||
this.chooseNote = false
|
||||
})
|
||||
} else {
|
||||
Image($r('app.media.zoom')).height(24).width(24)
|
||||
Image($r('app.media.zoom'))
|
||||
.height(24)
|
||||
.width(24)
|
||||
.onClick(() => {
|
||||
if (this.sectionStatus != 1) {
|
||||
this.lastSectionStatus = this.sectionStatus
|
||||
this.sectionStatus = 1
|
||||
this.controllerShow.runJavaScript({script:"RE.setInputEnabled(true)"})
|
||||
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setInputEnabled(true)" })
|
||||
} else {
|
||||
if (this.lastSectionStatus != undefined) {
|
||||
this.sectionStatus = this.lastSectionStatus
|
||||
// 切换为小屏预览模式
|
||||
this.controllerShow.runJavaScript({script:"RE.setInputEnabled(false)"})
|
||||
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setInputEnabled(false)" })
|
||||
// 退出全屏时存库
|
||||
LogUtil.info(TAG, "close note" + this.selectedNoteData.uuid)
|
||||
this.controllerShow.runJavaScript({script:"get_html_content()"})
|
||||
this.controllerShow.runJavaScript({ script: "save_html_content()" })
|
||||
this.sectionStatus = this.lastSectionStatus
|
||||
} else {
|
||||
this.sectionStatus = 3
|
||||
}
|
||||
@ -306,11 +346,15 @@ export struct ToolBarComp {
|
||||
|
||||
if (this.selectedNoteData.is_deleted == Delete.Yes) {
|
||||
Row({ space: StyleConstants.SPACE_24 }) {
|
||||
Image($r('app.media.delete')).height(24).width(24)
|
||||
Image($r('app.media.delete'))
|
||||
.height(24)
|
||||
.width(24)
|
||||
.onClick(() => {
|
||||
this.noteDataDeleteDialogCtl.open()
|
||||
})
|
||||
Image($r('app.media.recover')).height(24).width(24)
|
||||
Image($r('app.media.recover'))
|
||||
.height(24)
|
||||
.width(24)
|
||||
.onClick(() => {
|
||||
this.selectedNoteData.is_deleted = Delete.No
|
||||
this.selectedNoteData.deleted_time = 0
|
||||
@ -323,34 +367,52 @@ export struct ToolBarComp {
|
||||
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null)
|
||||
|
||||
this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid)
|
||||
this.controllerShow.runJavaScript({script:"RE.setHtml('" + this.selectedNoteData.content_text + "')"})
|
||||
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')" })
|
||||
// save continue data
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
|
||||
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
|
||||
console.log("recover, set continue note success")
|
||||
})
|
||||
}.width(72)
|
||||
.visibility(this.portraitModel ? Visibility.None : Visibility.Visible)
|
||||
} else if (this.portraitModel == true && this.editModel == true) {
|
||||
Row({ space: StyleConstants.SPACE_24 }) {
|
||||
Image($r('app.media.undo')).height(24).width(24)
|
||||
Image($r('app.media.undo'))
|
||||
.height(24)
|
||||
.width(24)
|
||||
.onClick(() => {
|
||||
this.controllerShow.runJavaScript({script:"javascript:RE.undo()"})
|
||||
this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.undo()" })
|
||||
})
|
||||
Image($r('app.media.todo')).height(24).width(24)
|
||||
Image($r('app.media.todo'))
|
||||
.height(24)
|
||||
.width(24)
|
||||
.onClick(() => {
|
||||
this.controllerShow.runJavaScript({script:"javascript:RE.redo()"})
|
||||
this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.redo()" })
|
||||
})
|
||||
Image($r('app.media.tick_thin')).height(24).width(24)
|
||||
Image($r('app.media.tick_thin'))
|
||||
.height(24)
|
||||
.width(24)
|
||||
.onClick(() => {
|
||||
// 保存笔记信息到数据库
|
||||
this.controllerShow.runJavaScript({ script: "get_html_content()" })
|
||||
if (this.selectedNoteData.title == "标题" && this.selectedNoteData.content_text == "") {
|
||||
LogUtil.info(TAG, "note is empty,save note failed")
|
||||
prompt.showToast({ message: $r('app.string.empty_note'), duration: 2000 })
|
||||
}
|
||||
})
|
||||
}.width(120)
|
||||
} else if (this.editModel == true) {
|
||||
Row({ space: StyleConstants.SPACE_24 }) {
|
||||
Image($r('app.media.circle_tick1')).height(24).width(24)
|
||||
Image($r('app.media.circle_tick1'))
|
||||
.height(24)
|
||||
.width(24)
|
||||
.onClick(() => {
|
||||
// 清单
|
||||
this.controllerShow.runJavaScript({script:"javascript:RE.setTodo()"})
|
||||
this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.setTodo()" })
|
||||
})
|
||||
Image($r('app.media.styles')).height(24).width(24)
|
||||
Image($r('app.media.styles'))
|
||||
.height(24)
|
||||
.width(24)
|
||||
.onClick(() => {
|
||||
if (this.portraitModel) {
|
||||
this.editContentDialogCtl.open()
|
||||
@ -358,30 +420,43 @@ export struct ToolBarComp {
|
||||
this.editContentDialogCtl.open()
|
||||
}
|
||||
})
|
||||
Image($r('app.media.picture_white')).height(24).width(24)
|
||||
Image($r('app.media.picture_white'))
|
||||
.height(24)
|
||||
.width(24)
|
||||
.onClick(() => {
|
||||
console.info('test select single select!')
|
||||
this.controllerShow.runJavaScript({script:"javascript:RE.insertImage()"})
|
||||
this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.insertImage()" })
|
||||
})
|
||||
Image($r('app.media.tick_thick')).height(24).width(24)
|
||||
Image($r('app.media.tick_thick'))
|
||||
.height(24)
|
||||
.width(24)
|
||||
.onClick(() => {
|
||||
// 保存笔记信息到数据库
|
||||
this.controllerShow.runJavaScript({ script: "get_html_content()" })
|
||||
if (this.selectedNoteData.title == "标题" && this.selectedNoteData.content_text == "") {
|
||||
LogUtil.info(TAG, "note is empty,save note failed")
|
||||
prompt.showToast({ message: $r('app.string.empty_note'), duration: 2000 })
|
||||
}
|
||||
})
|
||||
Image($r('app.media.undo')).height(24).width(24)
|
||||
Image($r('app.media.undo'))
|
||||
.height(24)
|
||||
.width(24)
|
||||
.onClick(() => {
|
||||
|
||||
this.controllerShow.runJavaScript({script:"RE.undo()"})
|
||||
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.undo()" })
|
||||
})
|
||||
Image($r('app.media.todo')).height(24).width(24)
|
||||
Image($r('app.media.todo'))
|
||||
.height(24)
|
||||
.width(24)
|
||||
.onClick(() => {
|
||||
this.controllerShow.runJavaScript({script:"RE.redo()"})
|
||||
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.redo()" })
|
||||
})
|
||||
}.width(268)
|
||||
} else {
|
||||
Row({ space: StyleConstants.SPACE_24 }) {
|
||||
Image(this.selectedNoteData.is_favorite == Favorite.Yes ? $r('app.media.favorite') : $r('app.media.favorite_cancel'))
|
||||
.height(24).width(24)
|
||||
.height(24)
|
||||
.width(24)
|
||||
.onClick(() => {
|
||||
this.selectedNoteData.is_favorite = (this.selectedNoteData.is_favorite == Favorite.Yes ? Favorite.No : Favorite.Yes)
|
||||
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
|
||||
@ -391,15 +466,15 @@ export struct ToolBarComp {
|
||||
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null)
|
||||
if (this.selectedFolderData.uuid === SysDefFolderUuid.MyFavorites) {
|
||||
this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), SysDefFolderUuid.MyFavorites)
|
||||
// 迁移
|
||||
console.log("ToolBarComp, set continue note")
|
||||
// save continue data
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
|
||||
console.log("ToolBarComp, continueNote : " + continueNote)
|
||||
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
|
||||
console.log("ToolBarComp, set continue note success")
|
||||
}
|
||||
})
|
||||
Image($r('app.media.delete')).height(24).width(24)
|
||||
Image($r('app.media.delete'))
|
||||
.height(24)
|
||||
.width(24)
|
||||
.onClick(() => {
|
||||
if (this.portraitModel) {
|
||||
this.noteDataDeleteDialogCtlBottom.open()
|
||||
@ -421,7 +496,7 @@ export struct DeleteNoteComp {
|
||||
@StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray')
|
||||
@Consume('SelectedFolderData') selectedFolderData: FolderData
|
||||
@Consume('RefreshFlag') refreshFlag: number
|
||||
@Consume('SelectedNoteData') selectedNoteData: NoteData;
|
||||
@Consume('SelectedNoteData') selectedNoteData: NoteData
|
||||
@Consume('PortraitModel') portraitModel: boolean
|
||||
@Consume('ChooseNote') chooseNote: boolean
|
||||
noteDataDeleteDialogCtlBottom: CustomDialogController = new CustomDialogController({
|
||||
@ -449,10 +524,8 @@ export struct DeleteNoteComp {
|
||||
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
|
||||
this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid)
|
||||
this.chooseNote = false
|
||||
// 迁移
|
||||
console.log("DeleteNoteComp, onDeleteConfirm, set continue note")
|
||||
// save continue data
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
|
||||
console.log("DeleteNoteComp, onDeleteConfirm, continueNote : " + continueNote)
|
||||
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
|
||||
console.log("DeleteNoteComp, onDeleteConfirm, set continue note success")
|
||||
}
|
||||
@ -467,7 +540,8 @@ export struct DeleteNoteComp {
|
||||
this.noteDataDeleteDialogCtlBottom.open()
|
||||
})
|
||||
Text($r("app.string.delete"))
|
||||
.fontSize(10).fontColor('#182431')
|
||||
.fontSize(10)
|
||||
.fontColor('#182431')
|
||||
.padding({ top: 5 })
|
||||
}
|
||||
.alignItems(HorizontalAlign.Center)
|
||||
@ -488,7 +562,8 @@ export struct DeleteNoteComp {
|
||||
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null)
|
||||
})
|
||||
Text($r("app.string.recover"))
|
||||
.fontSize(10).fontColor('#182431')
|
||||
.fontSize(10)
|
||||
.fontColor('#182431')
|
||||
.padding({ top: 5 })
|
||||
}
|
||||
.alignItems(HorizontalAlign.Center)
|
||||
@ -530,7 +605,9 @@ struct NoteDataMoveItemComp {
|
||||
.width('100%')
|
||||
.height(55)
|
||||
|
||||
Divider().color($r("app.color.divider_color_e4e4e4")).strokeWidth(1)
|
||||
Divider()
|
||||
.color($r("app.color.divider_color_e4e4e4"))
|
||||
.strokeWidth(1)
|
||||
}
|
||||
.padding({ left: 16 })
|
||||
}
|
||||
|
@ -0,0 +1,463 @@
|
||||
/**
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
import DateUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/DateUtil.ets'
|
||||
import RdbStoreUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/RdbStoreUtil.ets'
|
||||
import FolderData from '../../../../../../common/utils/src/main/ets/default/model/databaseModel/FolderData.ets'
|
||||
import NoteData from '../../../../../../common/utils/src/main/ets/default/model/databaseModel/NoteData.ets'
|
||||
import {TableName, NoteTableColumn, SysDefFolderUuid, Favorite, Delete
|
||||
} from '../../../../../../common/utils/src/main/ets/default/model/databaseModel/EnumData.ets'
|
||||
import StyleConstants from '../../../../../../common/utils/src/main/ets/default/constants/StyleConstants.ets'
|
||||
import {EditContentDialogPortrait, DeleteDialog, EditTitleDialog} from './CusDialogComp.ets'
|
||||
import FolderUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/FolderUtil.ets'
|
||||
import NoteUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/NoteUtil.ets'
|
||||
import prompt from '@system.prompt'
|
||||
import featureAbility from '@ohos.ability.featureAbility';
|
||||
import LogUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'
|
||||
|
||||
const TAG = "NoteContentComp"
|
||||
|
||||
// Note content component
|
||||
@Component
|
||||
export struct NoteContentCompPortrait {
|
||||
@Consume('SelectedNoteData') selectedNoteData: NoteData;
|
||||
@StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray')
|
||||
@Consume('SelectedFolderData') selectedFolderData: FolderData
|
||||
@Consume('RefreshFlag') refreshFlag: number
|
||||
@Consume('SectionStatus') sectionStatus: number
|
||||
@Consume('ChooseNote') chooseNote: boolean
|
||||
@Consume('EditModel') editModel: boolean
|
||||
private controllerShow: WebController = new WebController()
|
||||
private editContentFlag = false
|
||||
@State uri1: string = "";
|
||||
private context = getContext(this)
|
||||
noteContent = {
|
||||
callbackhtml: (html) => {
|
||||
LogUtil.info(TAG, 'html content is:' + html)
|
||||
LogUtil.info(TAG, 'note uuid is:' + this.selectedNoteData.uuid)
|
||||
this.selectedNoteData.content_text = html
|
||||
this.selectedNoteData.modified_time = new Date().getTime()
|
||||
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
|
||||
predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid)
|
||||
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null)
|
||||
LogUtil.info(TAG, 'update note success:' + this.selectedNoteData)
|
||||
return "AceString";
|
||||
}
|
||||
}
|
||||
|
||||
build() {
|
||||
Stack({ alignContent: Alignment.Bottom }) {
|
||||
Flex({ direction: FlexDirection.Column, wrap: FlexWrap.Wrap,
|
||||
alignItems: ItemAlign.Start, alignContent: FlexAlign.SpaceAround }) {
|
||||
Column() {
|
||||
ToolBarComp({ controllerShow: this.controllerShow })
|
||||
}
|
||||
|
||||
Column() {
|
||||
NoteContentOverViewComp()
|
||||
Text(this.refreshFlag.toString()).visibility(Visibility.None)
|
||||
Text(this.AllNoteArray.length.toString()).visibility(Visibility.None) // 用于强制刷新使用
|
||||
|
||||
Web({ src: $rawfile('editor.html'), controller: this.controllerShow })
|
||||
.javaScriptAccess(true)
|
||||
.onPageEnd((e) => {
|
||||
if (this.editContentFlag == false) {
|
||||
this.controllerShow.registerJavaScriptProxy({
|
||||
obj: this.noteContent,
|
||||
name: "callBackToApp", // html--> name.method
|
||||
methodList: ["callbackhtml"],
|
||||
});
|
||||
LogUtil.info(TAG, "finish register")
|
||||
this.controllerShow.refresh()
|
||||
this.editContentFlag = true
|
||||
}
|
||||
LogUtil.info(TAG, "finish loadurl")
|
||||
console.log('onPageEnd:' + e.url)
|
||||
// 初次进入预览模式
|
||||
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setInputEnabled(false)" })
|
||||
this.controllerShow.runJavaScript({
|
||||
script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')"
|
||||
})
|
||||
})
|
||||
.zoomAccess(false)
|
||||
.height(450)
|
||||
.width('100%')
|
||||
}
|
||||
.margin({ top: 16 })
|
||||
.width(StyleConstants.PERCENTAGE_100)
|
||||
.opacity(this.selectedNoteData.is_deleted == Delete.Yes ? 0.4 : 1)
|
||||
.enabled(this.selectedNoteData.is_deleted == Delete.Yes ? false : true)
|
||||
.onClick(() => {
|
||||
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setInputEnabled(true)" })
|
||||
this.editModel = true
|
||||
})
|
||||
}
|
||||
.height(StyleConstants.PERCENTAGE_100)
|
||||
.margin({ left: 24, right: 24 })
|
||||
.visibility(FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid) == 0 ? Visibility.Hidden : Visibility.Visible)
|
||||
|
||||
EditNoteCompForPortrait({ controllerShow: this.controllerShow })
|
||||
DeleteNoteComp()
|
||||
}
|
||||
.height(StyleConstants.PERCENTAGE_100)
|
||||
.width(StyleConstants.PERCENTAGE_100)
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
export struct NoteContentOverViewComp {
|
||||
@Consume('SelectedNoteData') selectedNoteData: NoteData;
|
||||
@StorageLink('AllFolderArray') AllFolderArray: FolderData[] = []
|
||||
@StorageLink('CheckedNoteArray') CheckedNoteArray: NoteData[] = []
|
||||
@Consume('SectionStatus') sectionStatus: number
|
||||
editTitleDialogCtl: CustomDialogController = new CustomDialogController({
|
||||
builder: EditTitleDialog({ confirm: this.confirm.bind(this), dialogType: 0 }),
|
||||
alignment: DialogAlignment.Center,
|
||||
autoCancel: false,
|
||||
customStyle: true,
|
||||
})
|
||||
|
||||
confirm(newTitle: string) {
|
||||
this.selectedNoteData.title = newTitle
|
||||
this.selectedNoteData.modified_time = new Date().getTime()
|
||||
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
|
||||
predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid)
|
||||
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null)
|
||||
}
|
||||
|
||||
@Builder MenuBuilder() {
|
||||
Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
||||
List() {
|
||||
ForEach(this.AllFolderArray, (item) => {
|
||||
ListItem() {
|
||||
NoteDataMoveItemComp({ folderItem: item })
|
||||
}
|
||||
.onClick(() => {
|
||||
this.selectedNoteData.folder_uuid = item.uuid
|
||||
})
|
||||
}, noteItem => noteItem.uuid)
|
||||
}.listDirection(Axis.Vertical)
|
||||
.edgeEffect(EdgeEffect.Spring)
|
||||
.height(this.AllFolderArray.length > 12 ? 504 : (this.AllFolderArray.length - 3) * 56)
|
||||
}
|
||||
.width(148)
|
||||
.backgroundColor($r("app.color.color_fffffB"))
|
||||
.padding({ left: 24, right: 24 })
|
||||
}
|
||||
|
||||
build() {
|
||||
Flex({ direction: FlexDirection.Column, wrap: FlexWrap.NoWrap,
|
||||
justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
|
||||
Row() {
|
||||
Text(this.selectedNoteData.title).fontSize(30)
|
||||
.onClick(() => {
|
||||
this.editTitleDialogCtl.open()
|
||||
})
|
||||
}.height(40).width(StyleConstants.PERCENTAGE_100)
|
||||
|
||||
Row() {
|
||||
Text(DateUtil.formateDateForNoteContent(new Date(this.selectedNoteData.modified_time))).fontSize(12)
|
||||
.padding({ top: 4, bottom: 4 })
|
||||
Row() {
|
||||
Text(FolderUtil.getFolderText(FolderUtil.getFolderData(AppStorage.Get('AllFolderArray'), this.selectedNoteData.folder_uuid)))
|
||||
.fontSize(12)
|
||||
Image($r('app.media.triangle'))
|
||||
.width(6)
|
||||
.height(12)
|
||||
.margin({ left: 4 })
|
||||
}
|
||||
.padding({ left: 8, right: 8, top: 4, bottom: 4 })
|
||||
.margin({ left: 8 })
|
||||
.borderRadius(16)
|
||||
.backgroundColor(NoteUtil.getNoteBgColor(AppStorage.Get('AllFolderArray'), this.selectedNoteData.folder_uuid, SysDefFolderUuid.AllNotes, false))
|
||||
.bindMenu(this.MenuBuilder)
|
||||
}.alignItems(VerticalAlign.Top).height(40).width(StyleConstants.PERCENTAGE_100)
|
||||
}
|
||||
.width(StyleConstants.PERCENTAGE_100)
|
||||
.height(80)
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
export struct ToolBarComp {
|
||||
@Consume('SelectedNoteData') selectedNoteData: NoteData;
|
||||
@Consume('RefreshFlag') refreshFlag: number
|
||||
@Consume('SectionStatus') sectionStatus: number
|
||||
@Consume('SelectedFolderData') selectedFolderData: FolderData
|
||||
@Consume('ChooseNote') chooseNote: boolean
|
||||
@Consume('PortraitModel') portraitModel: boolean
|
||||
@StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray')
|
||||
@Consume('EditModel') editModel: boolean
|
||||
controllerShow: WebController
|
||||
|
||||
build() {
|
||||
Flex({ direction: FlexDirection.Row, wrap: FlexWrap.NoWrap,
|
||||
justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
|
||||
|
||||
Image($r('app.media.back')).height(24).width(24)
|
||||
.onClick(() => {
|
||||
// 退出全屏时存库
|
||||
this.controllerShow.runJavaScript({ script: "get_html_content()" })
|
||||
// 删除空白笔记
|
||||
NoteUtil.deleteEmptyNote(this.selectedNoteData, this.AllNoteArray, this.controllerShow)
|
||||
this.chooseNote = false
|
||||
// 进入预览模式
|
||||
this.controllerShow.runJavaScript({ script: "RE.setInputEnabled(false)" })
|
||||
this.editModel = false
|
||||
})
|
||||
|
||||
if (this.editModel == false) {
|
||||
Row({ space: StyleConstants.SPACE_24 }) {
|
||||
Image(this.selectedNoteData.is_favorite == Favorite.Yes ? $r('app.media.favorite') : $r('app.media.favorite_cancel'))
|
||||
.height(24).width(24)
|
||||
.onClick(() => {
|
||||
this.selectedNoteData.is_favorite = (this.selectedNoteData.is_favorite == Favorite.Yes ? Favorite.No : Favorite.Yes)
|
||||
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
|
||||
// update note to db
|
||||
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
|
||||
predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid)
|
||||
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null)
|
||||
if (this.selectedFolderData.uuid === SysDefFolderUuid.MyFavorites) {
|
||||
this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), SysDefFolderUuid.MyFavorites)
|
||||
// 迁移
|
||||
console.log("ToolBarComp, set continue note")
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
|
||||
console.log("ToolBarComp, continueNote : " + continueNote)
|
||||
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
|
||||
console.log("ToolBarComp, set continue note success")
|
||||
}
|
||||
})
|
||||
}.width(36)
|
||||
.visibility(this.selectedNoteData.is_deleted == Delete.Yes ? Visibility.None : Visibility.Visible)
|
||||
} else {
|
||||
Row({ space: StyleConstants.SPACE_24 }) {
|
||||
Image($r('app.media.undo')).height(24).width(24)
|
||||
.onClick(() => {
|
||||
this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.undo()" })
|
||||
})
|
||||
Image($r('app.media.todo')).height(24).width(24)
|
||||
.onClick(() => {
|
||||
this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.redo()" })
|
||||
})
|
||||
Image($r('app.media.tick_thin')).height(24).width(24)
|
||||
.onClick(() => {
|
||||
// 保存笔记信息到数据库
|
||||
this.controllerShow.runJavaScript({ script: "get_html_content()" })
|
||||
if (this.selectedNoteData.title == "标题" && this.selectedNoteData.content_text == "") {
|
||||
LogUtil.info(TAG, "note is empty,save note failed")
|
||||
prompt.showToast({ message: $r('app.string.empty_note'), duration: 2000 })
|
||||
}
|
||||
// 进入预览模式
|
||||
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setInputEnabled(false)" })
|
||||
this.editModel = false
|
||||
})
|
||||
}
|
||||
.width(120)
|
||||
.visibility(this.selectedNoteData.is_deleted == Delete.Yes ? Visibility.None : Visibility.Visible)
|
||||
}
|
||||
}
|
||||
.width(StyleConstants.PERCENTAGE_100)
|
||||
.height(80)
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
export struct DeleteNoteComp {
|
||||
@StorageLink('CheckedNoteArray') CheckedNoteArray: NoteData[] = []
|
||||
@StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray')
|
||||
@Consume('SelectedFolderData') selectedFolderData: FolderData
|
||||
@Consume('RefreshFlag') refreshFlag: number
|
||||
@Consume('SelectedNoteData') selectedNoteData: NoteData;
|
||||
@Consume('PortraitModel') portraitModel: boolean
|
||||
@Consume('ChooseNote') chooseNote: boolean
|
||||
noteDataDeleteDialogCtlBottom: CustomDialogController = new CustomDialogController({
|
||||
builder: DeleteDialog({ onConfirm: this.onDeleteConfirm.bind(this), multiSelect: true }),
|
||||
alignment: DialogAlignment.Bottom,
|
||||
autoCancel: false,
|
||||
customStyle: true,
|
||||
})
|
||||
|
||||
onDeleteConfirm() {
|
||||
if (this.selectedFolderData.uuid != SysDefFolderUuid.RecentDeletes) {
|
||||
this.selectedNoteData.is_deleted = Delete.Yes
|
||||
this.selectedNoteData.deleted_time = new Date().getTime()
|
||||
// update note to db
|
||||
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
|
||||
predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid)
|
||||
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null)
|
||||
} else {
|
||||
NoteUtil.removeNoteData(this.AllNoteArray, this.selectedNoteData.uuid)
|
||||
// delete note from db
|
||||
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
|
||||
predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid)
|
||||
RdbStoreUtil.delete(predicates_note, null)
|
||||
}
|
||||
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
|
||||
this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid)
|
||||
this.chooseNote = false
|
||||
}
|
||||
|
||||
build() {
|
||||
Flex({ direction: FlexDirection.Row, wrap: FlexWrap.Wrap, justifyContent: FlexAlign.SpaceBetween }) {
|
||||
Column() {
|
||||
Image($r('app.media.delete'))
|
||||
.width(24)
|
||||
.height(24)
|
||||
.onClick(() => {
|
||||
this.noteDataDeleteDialogCtlBottom.open()
|
||||
})
|
||||
Text($r("app.string.delete"))
|
||||
.fontSize(10).fontColor('#182431')
|
||||
.padding({ top: 5 })
|
||||
}
|
||||
.alignItems(HorizontalAlign.Center)
|
||||
|
||||
Column() {
|
||||
Image($r('app.media.recover'))
|
||||
.width(24)
|
||||
.height(24)
|
||||
.onClick(() => {
|
||||
this.selectedNoteData.is_deleted = Delete.No
|
||||
this.selectedNoteData.deleted_time = 0
|
||||
prompt.showToast({ message: $r('app.string.restore'), duration: 2000 })
|
||||
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
|
||||
this.chooseNote = false
|
||||
// update note to db
|
||||
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
|
||||
predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid)
|
||||
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null)
|
||||
})
|
||||
Text($r("app.string.recover"))
|
||||
.fontSize(10).fontColor('#182431')
|
||||
.padding({ top: 5 })
|
||||
}
|
||||
.alignItems(HorizontalAlign.Center)
|
||||
}
|
||||
.width(360)
|
||||
.height(56)
|
||||
.visibility(this.selectedNoteData.is_deleted == Delete.Yes && this.portraitModel == true ?
|
||||
Visibility.Visible : Visibility.None)
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
export struct EditNoteCompForPortrait {
|
||||
@StorageLink('CheckedNoteArray') CheckedNoteArray: NoteData[] = []
|
||||
@StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray')
|
||||
@Consume('SelectedFolderData') selectedFolderData: FolderData
|
||||
@Consume('RefreshFlag') refreshFlag: number
|
||||
@Consume('SelectedNoteData') selectedNoteData: NoteData;
|
||||
@Consume('PortraitModel') portraitModel: boolean
|
||||
@Consume('ChooseNote') chooseNote: boolean
|
||||
@Consume('EditModel') editModel: boolean
|
||||
controllerShow: WebController
|
||||
editContentDialogCtl: CustomDialogController = new CustomDialogController({
|
||||
builder: EditContentDialogPortrait({ confirm: this.confirm.bind(this), dialogType: 0 }),
|
||||
alignment: DialogAlignment.Bottom,
|
||||
autoCancel: true,
|
||||
customStyle: true,
|
||||
})
|
||||
|
||||
confirm(excuteJs: string) {
|
||||
this.controllerShow.runJavaScript({ script: excuteJs })
|
||||
}
|
||||
|
||||
build() {
|
||||
Flex({ direction: FlexDirection.Row, wrap: FlexWrap.Wrap, justifyContent: FlexAlign.SpaceBetween }) {
|
||||
Column() {
|
||||
Image($r('app.media.circle_tick'))
|
||||
.width(24)
|
||||
.height(24)
|
||||
.onClick(() => {
|
||||
// 清单
|
||||
this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.setTodo()" })
|
||||
})
|
||||
Text($r("app.string.list"))
|
||||
.fontSize(10).fontColor('#182431')
|
||||
.padding({ top: 5 })
|
||||
}
|
||||
.alignItems(HorizontalAlign.Center)
|
||||
|
||||
Column() {
|
||||
Image($r('app.media.font_style'))
|
||||
.width(24)
|
||||
.height(24)
|
||||
.onClick(() => {
|
||||
this.editContentDialogCtl.open()
|
||||
})
|
||||
Text($r("app.string.style"))
|
||||
.fontSize(10).fontColor('#182431')
|
||||
.padding({ top: 5 })
|
||||
}
|
||||
.alignItems(HorizontalAlign.Center)
|
||||
|
||||
Column() {
|
||||
Image($r('app.media.picture_white'))
|
||||
.width(24)
|
||||
.height(24)
|
||||
.onClick(() => {
|
||||
})
|
||||
Text($r("app.string.photo"))
|
||||
.fontSize(10).fontColor('#182431')
|
||||
.padding({ top: 5 })
|
||||
}
|
||||
.alignItems(HorizontalAlign.Center)
|
||||
}
|
||||
.width(360)
|
||||
.height(56)
|
||||
.visibility(this.selectedNoteData.is_deleted == Delete.No && this.editModel == true ?
|
||||
Visibility.Visible : Visibility.None)
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
struct NoteDataMoveItemComp {
|
||||
@StorageLink('CheckedNoteArray') CheckedNoteArray: NoteData[] = []
|
||||
@StorageLink('AllFolderArray') AllFolderArray: FolderData[] = []
|
||||
private folderItem: FolderData
|
||||
|
||||
build() {
|
||||
Flex({ alignItems: ItemAlign.Center, wrap: FlexWrap.NoWrap, justifyContent: FlexAlign.Center }) {
|
||||
Flex({ alignItems: ItemAlign.Center, wrap: FlexWrap.NoWrap }) {
|
||||
Image(FolderUtil.getFolderIcon(this.folderItem.uuid))
|
||||
.objectFit(ImageFit.ScaleDown)
|
||||
.width(24)
|
||||
.height(24)
|
||||
.fillColor(FolderUtil.getFolderIconColor(this.AllFolderArray, this.folderItem.uuid, false))
|
||||
}
|
||||
.width(24)
|
||||
|
||||
Column() {
|
||||
Flex({ alignItems: ItemAlign.Center, wrap: FlexWrap.NoWrap, justifyContent: FlexAlign.SpaceBetween }) {
|
||||
Text(FolderUtil.getFolderText(this.folderItem))
|
||||
.fontSize(16)
|
||||
.fontColor(FolderUtil.getFolderIconColor(this.AllFolderArray, this.folderItem.uuid, false))
|
||||
.textAlign(TextAlign.Center)
|
||||
.maxLines(1)
|
||||
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
||||
.flexShrink(1)
|
||||
}
|
||||
.width('100%')
|
||||
.height(55)
|
||||
|
||||
Divider().color($r("app.color.divider_color_e4e4e4")).strokeWidth(1)
|
||||
}
|
||||
.padding({ left: 16 })
|
||||
}
|
||||
.width('100%')
|
||||
.height(56)
|
||||
.visibility(FolderUtil.isFolderMoveIn(this.folderItem) ? Visibility.Visible : Visibility.None)
|
||||
}
|
||||
}
|
@ -16,8 +16,7 @@
|
||||
import DateUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/DateUtil.ets'
|
||||
import FolderData from '../../../../../../common/utils/src/main/ets/default/model/databaseModel/FolderData.ets'
|
||||
import NoteData from '../../../../../../common/utils/src/main/ets/default/model/databaseModel/NoteData.ets'
|
||||
import {TableName, NoteTableColumn, SysDefFolderUuid, Favorite, Delete, Top, NoteType
|
||||
} from '../../../../../../common/utils/src/main/ets/default/model/databaseModel/EnumData.ets'
|
||||
import {TableName, NoteTableColumn, SysDefFolderUuid, Favorite, Delete, Top, NoteType} from '../../../../../../common/utils/src/main/ets/default/model/databaseModel/EnumData.ets'
|
||||
import {NoteDataMoveDialog, DeleteDialog} from './CusDialogComp.ets'
|
||||
import RdbStoreUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/RdbStoreUtil.ets'
|
||||
import prompt from '@system.prompt'
|
||||
@ -53,6 +52,15 @@ export struct NoteListComp {
|
||||
.height('100%')
|
||||
.width('100%')
|
||||
}
|
||||
|
||||
aboutToAppear(): void{
|
||||
LogUtil.info(TAG, "aboutToAppear")
|
||||
}
|
||||
|
||||
aboutToDisappear(): void{
|
||||
LogUtil.info(TAG, "aboutToDisappear")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Component
|
||||
@ -93,12 +101,15 @@ struct NoteOverViewComp {
|
||||
alignItems: ItemAlign.Start
|
||||
}) {
|
||||
Text(FolderUtil.getFolderText(this.selectedFolderData))
|
||||
.fontSize(30).fontColor('#182431')
|
||||
.fontSize(30)
|
||||
.fontColor('#182431')
|
||||
Row() {
|
||||
Text(FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid).toString())
|
||||
.fontSize(14).fontColor('#182431')
|
||||
.fontSize(14)
|
||||
.fontColor('#182431')
|
||||
Text($r("app.string.noteslist"))
|
||||
.fontSize(14).fontColor('#182431')
|
||||
.fontSize(14)
|
||||
.fontColor('#182431')
|
||||
}
|
||||
.visibility((FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid) == 0) ? Visibility.None : Visibility.Visible)
|
||||
}.visibility(this.longpress ? Visibility.None : Visibility.Visible)
|
||||
@ -113,9 +124,13 @@ struct NoteOverViewComp {
|
||||
NoteUtil.unsetAllNotesChecked(this.CheckedNoteArray)
|
||||
})
|
||||
Text(this.CheckedNoteArray.length == 0 ? $r("app.string.none_selected") : $r("app.string.selected", this.CheckedNoteArray.length))
|
||||
.fontSize(20).fontColor('#182431').margin({ left: 16 })
|
||||
}.alignItems(VerticalAlign.Center).visibility(this.longpress ? Visibility.Visible : Visibility.None)
|
||||
}.padding({ top: 8, bottom: 8 }).height('100%')
|
||||
.fontSize(20)
|
||||
.fontColor('#182431')
|
||||
.margin({ left: 16 })
|
||||
}.alignItems(VerticalAlign.Center)
|
||||
.visibility(this.longpress ? Visibility.Visible : Visibility.None)
|
||||
}.padding({ top: 8, bottom: 8 })
|
||||
.height('100%')
|
||||
|
||||
AddNoteComp({ controllerShow: this.controllerShow })
|
||||
OperateNoteComp({ controllerShow: this.controllerShow })
|
||||
@ -133,7 +148,7 @@ export struct NoteItemComp {
|
||||
public spans: any[]
|
||||
controllerShow: WebController
|
||||
@Consume('SelectedFolderData') selectedFolderData: FolderData
|
||||
@Consume('SelectedNoteData') selectedNoteData: NoteData;
|
||||
@Consume('SelectedNoteData') selectedNoteData: NoteData
|
||||
@StorageLink('AllFolderArray') AllFolderArray: FolderData[] = AppStorage.Link('AllFolderArray')
|
||||
@StorageLink('CheckedNoteArray') CheckedNoteArray: NoteData[] = []
|
||||
@Consume('Longpress') longpress: boolean
|
||||
@ -141,6 +156,7 @@ export struct NoteItemComp {
|
||||
@Consume('RefreshFlag') refreshFlag: number
|
||||
@Consume('Search') search: boolean
|
||||
@Consume('selectedAll') selectedAll: boolean
|
||||
@Consume('PortraitModel') portraitModel:boolean
|
||||
|
||||
build() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
|
||||
@ -149,11 +165,12 @@ export struct NoteItemComp {
|
||||
Column({ space: 2 }) {
|
||||
Row({ space: 8 }) {
|
||||
Image($r("app.media.verticalBar"))
|
||||
.height(16).width(4)
|
||||
.height(16)
|
||||
.width(4)
|
||||
.fillColor(NoteUtil.getVerticalBarBgColor(AppStorage.Get('AllFolderArray'), this.noteItem.folder_uuid))
|
||||
Text() {
|
||||
ForEach(this.spans.map((item1, index1) => {
|
||||
return { index: index1, data: item1 };
|
||||
return { index: index1, data: item1 }
|
||||
}), item => {
|
||||
|
||||
if (item.data.type == 0) {
|
||||
@ -170,9 +187,13 @@ export struct NoteItemComp {
|
||||
Text(DateUtil.formateDateForNoteTitle(new Date(this.noteItem.modified_time)))
|
||||
.fontSize(14)
|
||||
.fontColor('#182431')
|
||||
Image($r("app.media.favorite")).height(16).width(16)
|
||||
Image($r("app.media.favorite"))
|
||||
.height(16)
|
||||
.width(16)
|
||||
.visibility(this.noteItem.is_favorite == Favorite.Yes ? Visibility.Visible : Visibility.None)
|
||||
Image($r("app.media.topped")).height(16).width(16)
|
||||
Image($r("app.media.topped"))
|
||||
.height(16)
|
||||
.width(16)
|
||||
.visibility(this.noteItem.is_top == Top.Yes ? Visibility.Visible : Visibility.None)
|
||||
}
|
||||
.padding({ left: 12 })
|
||||
@ -186,11 +207,18 @@ export struct NoteItemComp {
|
||||
.borderRadius(12)
|
||||
.border({ width: 0.5, color: '#19182431' })
|
||||
Stack({ alignContent: Alignment.Center }) {
|
||||
Image($r("app.media.unChecked")).height(24).width(24)
|
||||
Image($r("app.media.checked")).width(24).height(24)
|
||||
Image($r("app.media.unChecked"))
|
||||
.height(24)
|
||||
.width(24)
|
||||
Image($r("app.media.checked"))
|
||||
.width(24)
|
||||
.height(24)
|
||||
.visibility(NoteUtil.isNoteChecked(this.CheckedNoteArray, this.noteItem) ? Visibility.Visible : Visibility.None)
|
||||
}.width(24).height(24).visibility(this.longpress ? Visibility.Visible : Visibility.None)
|
||||
}.height(48).width(this.longpress ? 80 : 48)
|
||||
}.width(24)
|
||||
.height(24)
|
||||
.visibility(this.longpress ? Visibility.Visible : Visibility.None)
|
||||
}.height(48)
|
||||
.width(this.longpress ? 80 : 48)
|
||||
}
|
||||
.width('100%')
|
||||
.height(72)
|
||||
@ -216,15 +244,14 @@ export struct NoteItemComp {
|
||||
} else {
|
||||
this.selectedNoteData = this.noteItem
|
||||
this.chooseNote = true
|
||||
// 迁移
|
||||
console.log("NoteItemComp, set continue note")
|
||||
// save continue data
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
|
||||
console.log("NoteItemComp, continueNote : " + continueNote)
|
||||
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
|
||||
console.log("NoteItemComp, set continue note success")
|
||||
}
|
||||
this.controllerShow.runJavaScript({script:"RE.setHtml('" + this.selectedNoteData.content_text + "')"})
|
||||
this.controllerShow.runJavaScript({script:"RE.updateRichTextState()"})
|
||||
if(this.portraitModel == false) {
|
||||
this.controllerShow.runJavaScript({script:"RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')" })
|
||||
}
|
||||
this.selectedAll = this.CheckedNoteArray.length ==
|
||||
NoteUtil.getNoteDataArray(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid).length
|
||||
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
|
||||
@ -254,7 +281,7 @@ export struct NoteItemListComp {
|
||||
@Consume('Search') search: boolean
|
||||
@Consume @Watch('doSearch') inputKeyword: string
|
||||
@Consume('SearchResultList') searchResultList: NoteData[]
|
||||
@Consume('SelectedNoteData') selectedNoteData: NoteData;
|
||||
@Consume('SelectedNoteData') selectedNoteData: NoteData
|
||||
controllerShow: WebController
|
||||
|
||||
doSearch() {
|
||||
@ -267,10 +294,8 @@ export struct NoteItemListComp {
|
||||
} else {
|
||||
this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid)
|
||||
}
|
||||
// 迁移
|
||||
console.log("doSearch, set continue note")
|
||||
// save continue data
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
|
||||
console.log("doSearch, continueNote : " + continueNote)
|
||||
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
|
||||
console.log("doSearch, set continue note success")
|
||||
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
|
||||
@ -286,7 +311,9 @@ export struct NoteItemListComp {
|
||||
.visibility((FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid) == 0) ? Visibility.None : Visibility.Visible)
|
||||
|
||||
Flex({ justifyContent: FlexAlign.Center }) {
|
||||
Text($r("app.string.permanently_delete_tips")).fontSize(12).fontColor('#18181A')
|
||||
Text($r("app.string.permanently_delete_tips"))
|
||||
.fontSize(12)
|
||||
.fontColor('#18181A')
|
||||
}
|
||||
.margin({ bottom: this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ? 12 : 0 })
|
||||
.width('100%')
|
||||
@ -296,11 +323,17 @@ export struct NoteItemListComp {
|
||||
List({ initialIndex: 0 }) {
|
||||
ListItem() {
|
||||
Column({ space: 8 }) {
|
||||
Image($r('app.media.emptyPage')).width(120).height(120)
|
||||
Text($r("app.string.Empty_page")).fontSize(12).fontColor('#A3A7AD')
|
||||
Image($r('app.media.emptyPage'))
|
||||
.width(120)
|
||||
.height(120)
|
||||
Text($r("app.string.Empty_page"))
|
||||
.fontSize(12)
|
||||
.fontColor('#A3A7AD')
|
||||
}
|
||||
}
|
||||
.width('100%').height('100%').padding({ bottom: 120 })
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
.padding({ bottom: 120 })
|
||||
.visibility((FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid) == 0) ? Visibility.Visible : Visibility.None)
|
||||
|
||||
ForEach(this.inputKeyword.length == 0 ?
|
||||
@ -335,7 +368,7 @@ export struct OperateNoteComp {
|
||||
@StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray')
|
||||
@Consume('SelectedFolderData') selectedFolderData: FolderData
|
||||
@Consume('RefreshFlag') refreshFlag: number
|
||||
@Consume('SelectedNoteData') selectedNoteData: NoteData;
|
||||
@Consume('SelectedNoteData') selectedNoteData: NoteData
|
||||
@Consume('PortraitModel') portraitModel: boolean
|
||||
@Consume('selectedAll') selectedAll: boolean
|
||||
controllerShow: WebController
|
||||
@ -388,11 +421,11 @@ export struct OperateNoteComp {
|
||||
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
|
||||
this.longpress = false
|
||||
this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid)
|
||||
this.controllerShow.runJavaScript({script:"RE.setHtml('" + this.selectedNoteData.content_text + "')"})
|
||||
// 迁移
|
||||
console.log("OperateNoteComp, set continue note")
|
||||
if(this.portraitModel == false) {
|
||||
this.controllerShow.runJavaScript({script:"RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')" })
|
||||
}
|
||||
// save continue data
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
|
||||
console.log("OperateNoteComp, continueNote : " + continueNote)
|
||||
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
|
||||
console.log("OperateNoteComp, set continue note success")
|
||||
}
|
||||
@ -447,7 +480,7 @@ export struct OperateNoteComp {
|
||||
this.CheckedNoteArray.forEach((noteItem) => {
|
||||
noteItem.is_deleted = Delete.No
|
||||
noteItem.deleted_time = 0
|
||||
prompt.showToast({ message: "已恢复", duration: 2000 })
|
||||
prompt.showToast({ message: $r('app.string.restore'), duration: 2000 })
|
||||
// update note to db
|
||||
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
|
||||
predicates_note.equalTo(NoteTableColumn.Uuid, noteItem.uuid)
|
||||
@ -481,17 +514,21 @@ export struct AddNoteComp {
|
||||
@StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray')
|
||||
@Consume('Longpress') longpress: boolean
|
||||
@Consume('SelectedFolderData') selectedFolderData: FolderData
|
||||
@Consume('SelectedNoteData') selectedNoteData: NoteData;
|
||||
@Consume('SelectedNoteData') selectedNoteData: NoteData
|
||||
@Consume('SectionStatus') sectionStatus: number
|
||||
@Consume('LastSectionStatus') lastSectionStatus: number
|
||||
@Consume('EditModel') editModel: boolean
|
||||
@Consume('ChooseNote') chooseNote: boolean
|
||||
@Consume('PortraitModel') portraitModel: boolean
|
||||
controllerShow: WebController
|
||||
|
||||
build() {
|
||||
Image($r('app.media.addNote'))
|
||||
.width(24).height(24).margin({ right: 12 })
|
||||
.width(24)
|
||||
.height(24)
|
||||
.margin({ right: 12 })
|
||||
.onClick(() => {
|
||||
let noteData = new NoteData(0,"标题",new Date().getTime() + "",SysDefFolderUuid.UnClassified,"","",NoteType.SysDef,Top.No,Favorite.No,Delete.No,new Date().getTime(),new Date().getTime(),0)
|
||||
let noteData = new NoteData(0, "标题", new Date().getTime() + "", this.selectedFolderData.uuid, "", "", NoteType.SysDef, Top.No, Favorite.No, Delete.No, new Date().getTime(), new Date().getTime(), 0)
|
||||
|
||||
this.AllNoteArray.push(noteData)
|
||||
RdbStoreUtil.insert(TableName.NoteTable, noteData.toNoteObject(), null)
|
||||
@ -501,12 +538,20 @@ export struct AddNoteComp {
|
||||
if (this.sectionStatus != 1) {
|
||||
this.lastSectionStatus = this.sectionStatus
|
||||
this.sectionStatus = 1
|
||||
this.controllerShow.runJavaScript({script:"RE.setInputEnabled(true)"})
|
||||
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setInputEnabled(true)" })
|
||||
} else {
|
||||
this.sectionStatus = this.lastSectionStatus
|
||||
}
|
||||
this.controllerShow.runJavaScript({script:"RE.setHtml('" + this.selectedNoteData.content_text + "')"})
|
||||
if(this.portraitModel == false) {
|
||||
this.controllerShow.runJavaScript({script:"RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')" })
|
||||
}
|
||||
this.editModel = true
|
||||
this.chooseNote = true
|
||||
// save continue data
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
|
||||
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
|
||||
AppStorage.SetOrCreate<number>('ContinueSection', this.sectionStatus)
|
||||
console.log("addNote, set continue note and section success")
|
||||
})
|
||||
.visibility(this.longpress || this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ? Visibility.None : Visibility.Visible)
|
||||
}
|
||||
@ -556,7 +601,7 @@ export struct OperateNoteCompForPortrait {
|
||||
@StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray')
|
||||
@Consume('SelectedFolderData') selectedFolderData: FolderData
|
||||
@Consume('RefreshFlag') refreshFlag: number
|
||||
@Consume('SelectedNoteData') selectedNoteData: NoteData;
|
||||
@Consume('SelectedNoteData') selectedNoteData: NoteData
|
||||
@Consume('PortraitModel') portraitModel: boolean
|
||||
noteDataMoveDialogCtlBottom: CustomDialogController = new CustomDialogController({
|
||||
builder: NoteDataMoveDialog({ onConfirm: this.onMoveConfirm.bind(this) }),
|
||||
@ -607,10 +652,8 @@ export struct OperateNoteCompForPortrait {
|
||||
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
|
||||
this.longpress = false
|
||||
this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid)
|
||||
// 迁移
|
||||
console.log("OperateNoteCompForPortrait, set continue note")
|
||||
// save continue data
|
||||
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
|
||||
console.log("OperateNoteCompForPortrait, continueNote : " + continueNote)
|
||||
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
|
||||
console.log("OperateNoteCompForPortrait, set continue note success")
|
||||
}
|
||||
@ -634,7 +677,8 @@ export struct OperateNoteCompForPortrait {
|
||||
NoteUtil.unsetAllNotesChecked(this.CheckedNoteArray)
|
||||
})
|
||||
Text($r("app.string.set_top"))
|
||||
.fontSize(10).fontColor('#182431')
|
||||
.fontSize(10)
|
||||
.fontColor('#182431')
|
||||
.padding({ top: 5 })
|
||||
}
|
||||
.opacity(this.CheckedNoteArray.length == 0 ? 0.4 : 1)
|
||||
@ -650,7 +694,8 @@ export struct OperateNoteCompForPortrait {
|
||||
this.noteDataDeleteDialogCtlBottom.open()
|
||||
})
|
||||
Text($r("app.string.delete"))
|
||||
.fontSize(10).fontColor('#182431')
|
||||
.fontSize(10)
|
||||
.fontColor('#182431')
|
||||
.padding({ top: 5 })
|
||||
}
|
||||
.opacity(this.CheckedNoteArray.length == 0 ? 0.4 : 1)
|
||||
@ -666,7 +711,8 @@ export struct OperateNoteCompForPortrait {
|
||||
this.noteDataMoveDialogCtlBottom.open()
|
||||
})
|
||||
Text($r("app.string.move"))
|
||||
.fontSize(10).fontColor('#182431')
|
||||
.fontSize(10)
|
||||
.fontColor('#182431')
|
||||
.padding({ top: 5 })
|
||||
}
|
||||
.opacity(this.CheckedNoteArray.length == 0 ? 0.4 : 1)
|
||||
@ -684,7 +730,7 @@ export struct OperateNoteCompForPortrait {
|
||||
this.CheckedNoteArray.forEach((noteItem) => {
|
||||
noteItem.is_deleted = Delete.No
|
||||
noteItem.deleted_time = 0
|
||||
prompt.showToast({ message: "已恢复", duration: 2000 })
|
||||
prompt.showToast({ message: $r('app.string.restore'), duration: 2000 })
|
||||
// update note to db
|
||||
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
|
||||
predicates_note.equalTo(NoteTableColumn.Uuid, noteItem.uuid)
|
||||
@ -695,7 +741,8 @@ export struct OperateNoteCompForPortrait {
|
||||
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
|
||||
})
|
||||
Text($r("app.string.recover"))
|
||||
.fontSize(10).fontColor('#182431')
|
||||
.fontSize(10)
|
||||
.fontColor('#182431')
|
||||
.padding({ top: 5 })
|
||||
}
|
||||
.opacity(this.CheckedNoteArray.length == 0 ? 0.4 : 1)
|
||||
@ -718,7 +765,8 @@ export struct OperateNoteCompForPortrait {
|
||||
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
|
||||
})
|
||||
Text($r("app.string.check_all"))
|
||||
.fontSize(10).fontColor('#182431')
|
||||
.fontSize(10)
|
||||
.fontColor('#182431')
|
||||
.padding({ top: 5 })
|
||||
}
|
||||
.alignItems(HorizontalAlign.Center)
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
import LogUtil from './LogUtil.ets'
|
||||
import GlobalResourceManager from './GlobalResourceManager.ets'
|
||||
|
||||
const TAG = "DateUtil"
|
||||
|
||||
/**
|
||||
@ -119,4 +120,5 @@ export class DateUtil {
|
||||
}
|
||||
|
||||
let dateUtil = new DateUtil()
|
||||
|
||||
export default dateUtil as DateUtil
|
@ -59,5 +59,4 @@ export default {
|
||||
}
|
||||
AppStorage.SetOrCreate('DBQueryFinished', 1)
|
||||
}
|
||||
|
||||
}
|
@ -21,6 +21,7 @@ import StyleConstants from '../constants/StyleConstants.ets'
|
||||
import LogUtil from './LogUtil.ets'
|
||||
|
||||
const TAG = "FolderUtil"
|
||||
|
||||
export class FolderUtil {
|
||||
/**
|
||||
* Get Folder Data
|
||||
@ -129,10 +130,18 @@ export class FolderUtil {
|
||||
getNoteCount(noteDataArray: NoteData[], folderUuid: string): number {
|
||||
let count = 0;
|
||||
const folderTextMap = {
|
||||
"sys_def_allNotes_uuid": (noteData) => {noteData.is_deleted == Delete.No ? ++count : count},
|
||||
"sys_def_recentDeletes_uuid": (noteData) => {noteData.is_deleted == Delete.Yes ? ++count : count},
|
||||
"sys_def_myFavorites_uuid": (noteData) => {noteData.is_favorite == Favorite.Yes && noteData.is_deleted == Delete.No ? ++count : count},
|
||||
"sys_def_other_uuid": (noteData) => {noteData.folder_uuid == folderUuid && noteData.is_deleted == Delete.No ? ++count : count},
|
||||
"sys_def_allNotes_uuid": (noteData) => {
|
||||
noteData.is_deleted == Delete.No ? ++count : count
|
||||
},
|
||||
"sys_def_recentDeletes_uuid": (noteData) => {
|
||||
noteData.is_deleted == Delete.Yes ? ++count : count
|
||||
},
|
||||
"sys_def_myFavorites_uuid": (noteData) => {
|
||||
noteData.is_favorite == Favorite.Yes && noteData.is_deleted == Delete.No ? ++count : count
|
||||
},
|
||||
"sys_def_other_uuid": (noteData) => {
|
||||
noteData.folder_uuid == folderUuid && noteData.is_deleted == Delete.No ? ++count : count
|
||||
},
|
||||
}
|
||||
if (folderUuid == SysDefFolderUuid.AllNotes || folderUuid == SysDefFolderUuid.RecentDeletes || folderUuid == SysDefFolderUuid.MyFavorites) {
|
||||
noteDataArray.forEach(folderTextMap[folderUuid])
|
||||
@ -186,8 +195,8 @@ export class FolderUtil {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let folderUtil = new FolderUtil()
|
||||
|
||||
export default folderUtil as FolderUtil
|
@ -13,10 +13,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import Rsm from '@ohos.resourceManager';
|
||||
|
||||
const TAG = "Note_GlobalResourceManager"
|
||||
|
||||
export class GlobalResourceManager {
|
||||
|
||||
public async getStringByResource(res: any): Promise<string> {
|
||||
let json = JSON.parse(JSON.stringify(res));
|
||||
let id = json.id;
|
||||
@ -46,5 +46,6 @@ export class GlobalResourceManager {
|
||||
}
|
||||
|
||||
let mGlobalResourceManager = new GlobalResourceManager();
|
||||
|
||||
export default mGlobalResourceManager as GlobalResourceManager
|
||||
;
|
||||
|
@ -39,4 +39,5 @@ export class LayoutUtil {
|
||||
}
|
||||
|
||||
let layoutUtil = new LayoutUtil()
|
||||
|
||||
export default layoutUtil as LayoutUtil
|
@ -69,4 +69,5 @@ export class LogUtil {
|
||||
}
|
||||
|
||||
let mLogUtil = new LogUtil();
|
||||
|
||||
export default mLogUtil as LogUtil
|
@ -21,6 +21,7 @@ import StyleConstants from '../constants/StyleConstants.ets'
|
||||
import LogUtil from './LogUtil.ets'
|
||||
import FolderUtil from './FolderUtil.ets'
|
||||
import RdbStoreUtil from './RdbStoreUtil.ets'
|
||||
import prompt from '@system.prompt'
|
||||
|
||||
const TAG = "NoteUtil"
|
||||
|
||||
@ -100,10 +101,18 @@ export class NoteUtil {
|
||||
getNoteCount(noteDataArray: NoteData[], folderData: FolderData): number {
|
||||
let count = 0;
|
||||
const folderTextMap = {
|
||||
"sys_def_allNotes_uuid": (noteData) => {noteData.is_deleted == Delete.No ? ++count : count},
|
||||
"sys_def_recentDeletes_uuid": (noteData) => {noteData.is_deleted == Delete.Yes ? ++count : count},
|
||||
"sys_def_myFavorites_uuid": (noteData) => {noteData.is_favorite == Favorite.Yes && noteData.is_deleted == Delete.No ? ++count : count},
|
||||
"sys_def_other_uuid": (noteData) => {noteData.folder_uuid == folderData.uuid && noteData.is_deleted == Delete.No ? ++count : count}
|
||||
"sys_def_allNotes_uuid": (noteData) => {
|
||||
noteData.is_deleted == Delete.No ? ++count : count
|
||||
},
|
||||
"sys_def_recentDeletes_uuid": (noteData) => {
|
||||
noteData.is_deleted == Delete.Yes ? ++count : count
|
||||
},
|
||||
"sys_def_myFavorites_uuid": (noteData) => {
|
||||
noteData.is_favorite == Favorite.Yes && noteData.is_deleted == Delete.No ? ++count : count
|
||||
},
|
||||
"sys_def_other_uuid": (noteData) => {
|
||||
noteData.folder_uuid == folderData.uuid && noteData.is_deleted == Delete.No ? ++count : count
|
||||
}
|
||||
}
|
||||
if (folderData.uuid == SysDefFolderUuid.AllNotes || folderData.folder_type == FolderType.FeatureDef) {
|
||||
noteDataArray.forEach(folderTextMap[folderData.uuid])
|
||||
@ -181,10 +190,18 @@ export class NoteUtil {
|
||||
let noteDataArray: NoteData[] = [];
|
||||
let func = (noteData) => noteDataArray.push(noteData)
|
||||
const folderTextMap = {
|
||||
"sys_def_allNotes_uuid": (noteData) => {noteData.is_deleted == Delete.No ? func(noteData) : null},
|
||||
"sys_def_recentDeletes_uuid": (noteData) => {noteData.is_deleted == Delete.Yes ? func(noteData) : null},
|
||||
"sys_def_myFavorites_uuid": (noteData) => {noteData.is_favorite == Favorite.Yes && noteData.is_deleted == Delete.No ? func(noteData) : null},
|
||||
"sys_def_other_uuid": (noteData) => {noteData.folder_uuid == folderUuid && noteData.is_deleted == Delete.No ? func(noteData) : null},
|
||||
"sys_def_allNotes_uuid": (noteData) => {
|
||||
noteData.is_deleted == Delete.No ? func(noteData) : null
|
||||
},
|
||||
"sys_def_recentDeletes_uuid": (noteData) => {
|
||||
noteData.is_deleted == Delete.Yes ? func(noteData) : null
|
||||
},
|
||||
"sys_def_myFavorites_uuid": (noteData) => {
|
||||
noteData.is_favorite == Favorite.Yes && noteData.is_deleted == Delete.No ? func(noteData) : null
|
||||
},
|
||||
"sys_def_other_uuid": (noteData) => {
|
||||
noteData.folder_uuid == folderUuid && noteData.is_deleted == Delete.No ? func(noteData) : null
|
||||
},
|
||||
}
|
||||
if (folderUuid == SysDefFolderUuid.AllNotes || folderUuid == SysDefFolderUuid.RecentDeletes || folderUuid == SysDefFolderUuid.MyFavorites) {
|
||||
allNoteDataArray.forEach(folderTextMap[folderUuid])
|
||||
@ -229,7 +246,7 @@ export class NoteUtil {
|
||||
index == -1 ? null : allNoteDataArray.splice(index, 1)
|
||||
}
|
||||
|
||||
deleteEmptyNote(selectedNoteData: NoteData, AllNoteArray: NoteData[],controllerShow: WebController) {
|
||||
deleteEmptyNote(selectedNoteData: NoteData, AllNoteArray: NoteData[],controllerShow: WebController):boolean {
|
||||
LogUtil.info(TAG, selectedNoteData.content_text)
|
||||
if (selectedNoteData.title == "标题" && selectedNoteData.content_text == "") {
|
||||
// delete note from db
|
||||
@ -240,11 +257,12 @@ export class NoteUtil {
|
||||
predicates_note.equalTo(NoteTableColumn.Uuid, selectedNoteData.uuid)
|
||||
RdbStoreUtil.delete(predicates_note, null)
|
||||
LogUtil.info(TAG, "delete note success:" + selectedNoteData.uuid)
|
||||
selectedNoteData = AllNoteArray[0]
|
||||
controllerShow.runJavaScript({script:"RE.setHtml('" + selectedNoteData.content_text + "')"})
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
let noteUtil = new NoteUtil()
|
||||
|
||||
export default noteUtil as NoteUtil
|
@ -15,10 +15,11 @@
|
||||
|
||||
import ohosDataRdb from '@ohos.data.rdb'
|
||||
import LogUtil from './LogUtil.ets'
|
||||
import FolderUtil from './FolderUtil.ets'
|
||||
import SysDefData from '../model/databaseModel/SysDefData.ets'
|
||||
import FolderData from '../model/databaseModel/FolderData.ets'
|
||||
import NoteData from '../model/databaseModel/NoteData.ets'
|
||||
import {TableSql, TableName, FolderTableColumn, NoteTableColumn} from '../model/databaseModel/EnumData.ets'
|
||||
import {TableSql, TableName, FolderTableColumn, NoteTableColumn, SysDefFolderUuid} from '../model/databaseModel/EnumData.ets'
|
||||
|
||||
const TAG = "RdbStoreUtil"
|
||||
|
||||
@ -44,28 +45,19 @@ export default {
|
||||
LogUtil.info(TAG, "create table success")
|
||||
// insert system defined folder
|
||||
await rdbStore.insert(TableName.FolderTable, SysDefData.sys_def_allNotes)
|
||||
LogUtil.info(TAG, "insert sys_def_allNotes success")
|
||||
await rdbStore.insert(TableName.FolderTable, SysDefData.sys_def_unClassified)
|
||||
LogUtil.info(TAG, "insert sys_def_unClassified success")
|
||||
await rdbStore.insert(TableName.FolderTable, SysDefData.sys_def_myFavorites)
|
||||
LogUtil.info(TAG, "insert sys_def_myFavorites success")
|
||||
await rdbStore.insert(TableName.FolderTable, SysDefData.sys_def_recentDeletes)
|
||||
LogUtil.info(TAG, "insert sys_def_recentDeletes success")
|
||||
await rdbStore.insert(TableName.FolderTable, SysDefData.sys_def_personal)
|
||||
LogUtil.info(TAG, "insert sys_def_personal success")
|
||||
await rdbStore.insert(TableName.FolderTable, SysDefData.sys_def_life)
|
||||
LogUtil.info(TAG, "insert sys_def_life success")
|
||||
await rdbStore.insert(TableName.FolderTable, SysDefData.sys_def_work)
|
||||
LogUtil.info(TAG, "insert sys_def_work success")
|
||||
LogUtil.info(TAG, "insert system defined folder success")
|
||||
// insert system defined note and attachment
|
||||
await rdbStore.insert(TableName.NoteTable, SysDefData.sys_def_note1)
|
||||
LogUtil.info(TAG, "insert sys_def_note1 success")
|
||||
await rdbStore.insert(TableName.NoteTable, SysDefData.sys_def_note2)
|
||||
LogUtil.info(TAG, "insert sys_def_note2 success")
|
||||
await rdbStore.insert(TableName.NoteTable, SysDefData.sys_def_note3)
|
||||
LogUtil.info(TAG, "insert sys_def_note3 success")
|
||||
await rdbStore.insert(TableName.NoteTable, SysDefData.sys_def_note4)
|
||||
LogUtil.info(TAG, "insert sys_def_note4 success")
|
||||
LogUtil.info(TAG, "insert system defined note and attachment success")
|
||||
|
||||
// add sys-def folder and note to AppStorage
|
||||
let folderDataArray = []
|
||||
@ -78,6 +70,8 @@ export default {
|
||||
sysDefFolder.modified_time)
|
||||
folderDataArray.push(folderData)
|
||||
})
|
||||
LogUtil.info(TAG, "folderDataArray[sysdef] : " + folderDataArray.length)
|
||||
|
||||
let noteDataArray = []
|
||||
let sysDefNoteArray = [SysDefData.sys_def_note1, SysDefData.sys_def_note2,
|
||||
SysDefData.sys_def_note3, SysDefData.sys_def_note4]
|
||||
@ -87,28 +81,20 @@ export default {
|
||||
sysDefNote.is_deleted, sysDefNote.created_time, sysDefNote.modified_time, sysDefNote.deleted_time)
|
||||
noteDataArray.push(noteData)
|
||||
})
|
||||
LogUtil.info(TAG, "folderDataArray[sysdef] : " + folderDataArray.length)
|
||||
for (let folderData of folderDataArray) {
|
||||
LogUtil.info(TAG, "folderData[sysdef] : " + JSON.stringify(folderData))
|
||||
}
|
||||
LogUtil.info(TAG, "noteDataArray[sysdef] : " + noteDataArray.length)
|
||||
for (let noteData of noteDataArray) {
|
||||
LogUtil.info(TAG, "noteData[sysdef] : " + JSON.stringify(noteData))
|
||||
}
|
||||
|
||||
AppStorage.SetOrCreate('AllFolderArray', folderDataArray)
|
||||
AppStorage.SetOrCreate('AllNoteArray', noteDataArray)
|
||||
LogUtil.info(TAG, "AppStorage[sysdef] set AllFolderArray and AllNoteArray success")
|
||||
|
||||
// 迁移
|
||||
// save continue data
|
||||
let isContinue = AppStorage.Get('IsContinue');
|
||||
LogUtil.info(TAG, "createRdbStore, isContinue is " + isContinue)
|
||||
if (isContinue != undefined && isContinue == 1) {
|
||||
console.info("RdbStoreUtil createRdbStore, IsContinue true")
|
||||
let continueFolder: string = AppStorage.Get('ContinueFolder')
|
||||
console.log("RdbStoreUtil createRdbStore, continueFolder is " + continueFolder)
|
||||
let continueNote: string = AppStorage.Get('ContinueNote')
|
||||
console.log("RdbStoreUtil createRdbStore, continueNote is " + continueNote)
|
||||
let continueSection = AppStorage.Get('ContinueSection')
|
||||
console.log("RdbStoreUtil createRdbStore, continueSection is " + continueSection)
|
||||
|
||||
let folderObj = JSON.parse(continueFolder)
|
||||
let folderData = new FolderData(folderObj.uuid, folderObj.name, folderObj.uuid, folderObj.color,
|
||||
@ -119,7 +105,27 @@ export default {
|
||||
noteObj.content_text, noteObj.content_img, noteObj.note_type, noteObj.is_top, noteObj.is_favorite,
|
||||
noteObj.is_deleted, noteObj.created_time, noteObj.modified_time, noteObj.deleted_time)
|
||||
|
||||
AppStorage.SetOrCreate('Folder', folderData)
|
||||
// if not exit this note
|
||||
let exist = false
|
||||
let folderUuid = ""
|
||||
for (let note of noteDataArray) {
|
||||
if (noteData.created_time == note.created_time) {
|
||||
exist = true
|
||||
folderUuid = note.folder_uuid
|
||||
break
|
||||
}
|
||||
}
|
||||
console.log("RdbStoreUtil initAppStorage, exist : " + exist)
|
||||
// 迁移过来的笔记在本地不存在,则保存在未分类文件夹
|
||||
if (!exist) {
|
||||
noteData.folder_uuid = SysDefFolderUuid.UnClassified
|
||||
noteDataArray.push(noteData)
|
||||
AppStorage.SetOrCreate('AllNoteArray', noteDataArray)
|
||||
this.insert(TableName.NoteTable, noteData.toNoteObject(), null)
|
||||
AppStorage.SetOrCreate('Folder', FolderUtil.getFolderData(folderDataArray, SysDefFolderUuid.UnClassified))
|
||||
} else {
|
||||
AppStorage.SetOrCreate('Folder', FolderUtil.getFolderData(folderDataArray, folderUuid))
|
||||
}
|
||||
AppStorage.SetOrCreate('Note', noteData)
|
||||
AppStorage.SetOrCreate('Section', continueSection)
|
||||
} else {
|
||||
@ -162,7 +168,7 @@ export default {
|
||||
let folderData = new FolderData(id, name, uuid, color, folder_type, is_deleted, created_time, modified_time)
|
||||
folderDataArray.push(folderData)
|
||||
}
|
||||
LogUtil.info(TAG, "query folder table success")
|
||||
LogUtil.info(TAG, "folderDataArray[query] : " + folderDataArray.length)
|
||||
// query note
|
||||
let columns_note = []
|
||||
let predicates_note = new ohosDataRdb.RdbPredicates(TableName.NoteTable)
|
||||
@ -184,29 +190,19 @@ export default {
|
||||
let noteData = new NoteData(id, title, uuid, folder_uuid, content_text, content_img, noteType, is_top, is_favorite, is_deleted, created_time, modified_time, deleted_time)
|
||||
noteDataArray.push(noteData)
|
||||
}
|
||||
LogUtil.info(TAG, "query note table success")
|
||||
LogUtil.info(TAG, "folderDataArray[query] : " + folderDataArray.length)
|
||||
for (let folderData of folderDataArray) {
|
||||
LogUtil.info(TAG, "folderData[query] : " + JSON.stringify(folderData))
|
||||
}
|
||||
LogUtil.info(TAG, "noteDataArray[query] : " + noteDataArray.length)
|
||||
for (let noteData of noteDataArray) {
|
||||
LogUtil.info(TAG, "noteData[query] : " + JSON.stringify(noteData))
|
||||
}
|
||||
|
||||
AppStorage.SetOrCreate('AllFolderArray', folderDataArray)
|
||||
AppStorage.SetOrCreate('AllNoteArray', noteDataArray)
|
||||
LogUtil.info(TAG, "AppStorage[query] set AllFolderArray and AllNoteArray success")
|
||||
|
||||
// 迁移
|
||||
let isContinue = AppStorage.Get('IsContinue');
|
||||
LogUtil.info(TAG, "initAppStorage, isContinue is " + isContinue)
|
||||
if (isContinue != undefined && isContinue == 1) {
|
||||
console.info("RdbStoreUtil initAppStorage, IsContinue true")
|
||||
let continueFolder: string = AppStorage.Get('ContinueFolder')
|
||||
console.log("RdbStoreUtil initAppStorage, continueFolder is " + continueFolder)
|
||||
let continueNote: string = AppStorage.Get('ContinueNote')
|
||||
console.log("RdbStoreUtil initAppStorage, continueNote is " + continueNote)
|
||||
let continueSection = AppStorage.Get('ContinueSection')
|
||||
console.log("RdbStoreUtil initAppStorage, continueSection is " + continueSection)
|
||||
|
||||
let folderObj = JSON.parse(continueFolder)
|
||||
let folderData = new FolderData(folderObj.uuid, folderObj.name, folderObj.uuid, folderObj.color,
|
||||
@ -217,7 +213,27 @@ export default {
|
||||
noteObj.content_text, noteObj.content_img, noteObj.note_type, noteObj.is_top, noteObj.is_favorite,
|
||||
noteObj.is_deleted, noteObj.created_time, noteObj.modified_time, noteObj.deleted_time)
|
||||
|
||||
AppStorage.SetOrCreate('Folder', folderData)
|
||||
// if not exit this note
|
||||
let exist = false
|
||||
let folderUuid = ""
|
||||
for (let note of noteDataArray) {
|
||||
if (noteData.created_time == note.created_time) {
|
||||
exist = true
|
||||
folderUuid = note.folder_uuid
|
||||
break
|
||||
}
|
||||
}
|
||||
console.log("RdbStoreUtil initAppStorage, exist : " + exist)
|
||||
// 迁移过来的笔记在本地不存在,则保存在未分类文件夹
|
||||
if (!exist) {
|
||||
noteData.folder_uuid = SysDefFolderUuid.UnClassified
|
||||
noteDataArray.push(noteData)
|
||||
AppStorage.SetOrCreate('AllNoteArray', noteDataArray)
|
||||
this.insert(TableName.NoteTable, noteData.toNoteObject(), null)
|
||||
AppStorage.SetOrCreate('Folder', FolderUtil.getFolderData(folderDataArray, SysDefFolderUuid.UnClassified))
|
||||
} else {
|
||||
AppStorage.SetOrCreate('Folder', FolderUtil.getFolderData(folderDataArray, folderUuid))
|
||||
}
|
||||
AppStorage.SetOrCreate('Note', noteData)
|
||||
AppStorage.SetOrCreate('Section', continueSection)
|
||||
} else {
|
||||
|
35
common/utils/src/main/ets/default/baseUtil/WebViewUtil.ets
Normal file
@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Copyright (c) 2022 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* WebView Util
|
||||
*/
|
||||
export class WebViewUtil {
|
||||
private static controllerShow: WebController
|
||||
|
||||
private constructor() {
|
||||
|
||||
}
|
||||
|
||||
public static getWebController(): WebController{
|
||||
console.info('WebViewUtil, getWebController')
|
||||
if (!this.controllerShow) {
|
||||
console.info('WebViewUtil, controllerShow is null')
|
||||
this.controllerShow = new WebController()
|
||||
}
|
||||
return this.controllerShow
|
||||
}
|
||||
|
||||
}
|
@ -25,6 +25,7 @@ export const circleColorArray: string[] = [
|
||||
"#3f56ea", // 深蓝
|
||||
"#8a2be2", // 紫色
|
||||
]
|
||||
|
||||
export const fontColorArray: string[] = [
|
||||
"#e84026", // 深红
|
||||
"#ffbf00", // 黄色
|
||||
@ -84,6 +85,7 @@ export class WidthWeightMessage {
|
||||
noteListVisibility: number
|
||||
noteCotentWeight: string
|
||||
noteCotentVisibility: number
|
||||
|
||||
constructor(folderListWeight: string, folderListVisibility: number, noteListWeight: string, noteListVisibility: number,
|
||||
noteCotentWeight: string, noteCotentVisibility: number) {
|
||||
this.folderListWeight = folderListWeight
|
||||
@ -98,6 +100,7 @@ export class WidthWeightMessage {
|
||||
let widthWeightOneSection: WidthWeightMessage = new WidthWeightMessage("0%", 0, "0%", 0, "100%", 1)
|
||||
let widthWeightTwoSection = new WidthWeightMessage("0%", 0, "34%", 1, "66%", 1)
|
||||
let widthWeightThreeSection = new WidthWeightMessage("16%", 1, "34%", 1, "50%", 1)
|
||||
|
||||
export const widthWeightMessageMap = {
|
||||
1: widthWeightOneSection,
|
||||
2: widthWeightTwoSection,
|
||||
|
@ -81,4 +81,5 @@ export class SearchModel {
|
||||
}
|
||||
|
||||
let searchModel = new SearchModel()
|
||||
|
||||
export default searchModel as SearchModel
|
BIN
figures/ds_build_haps.png
Normal file
After Width: | Height: | Size: 90 KiB |
BIN
figures/ds_hilog_window.png
Normal file
After Width: | Height: | Size: 73 KiB |
BIN
figures/ds_ohosbuild_output_dir_release.png
Normal file
After Width: | Height: | Size: 116 KiB |
BIN
figures/ds_ohosbuild_variants.png
Normal file
After Width: | Height: | Size: 28 KiB |
BIN
figures/hdc_std.png
Normal file
After Width: | Height: | Size: 35 KiB |
BIN
figures/install.png
Normal file
After Width: | Height: | Size: 96 KiB |
BIN
figures/note.png
Normal file
After Width: | Height: | Size: 34 KiB |
BIN
figures/signature_1.png
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
figures/signature_2.png
Normal file
After Width: | Height: | Size: 149 KiB |
BIN
figures/signature_3.png
Normal file
After Width: | Height: | Size: 427 KiB |
@ -39,7 +39,7 @@
|
||||
"description": "$string:description_mainability",
|
||||
"label": "$string:entry_MainAbility",
|
||||
"type": "page",
|
||||
"launchType": "singleton",
|
||||
"launchType": "standard",
|
||||
"srcPath": "MainAbility",
|
||||
"srcLanguage": "ets",
|
||||
"metaData": {
|
||||
|
@ -39,7 +39,7 @@
|
||||
"description": "$string:description_mainability",
|
||||
"label": "$string:entry_MainAbility",
|
||||
"type": "page",
|
||||
"launchType": "singleton",
|
||||
"launchType": "standard",
|
||||
"srcPath": "MainAbility",
|
||||
"srcLanguage": "ets",
|
||||
"metaData": {
|
||||
|
7
product/phone/src/main/ets/AbilityStage.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import AbilityStage from "@ohos.application.AbilityStage"
|
||||
|
||||
export default class MyAbilityStage extends AbilityStage {
|
||||
onCreate() {
|
||||
console.log("MyAbilityStage onCreate")
|
||||
}
|
||||
}
|
28
product/phone/src/main/ets/MainAbility/MainAbility.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import Ability from '@ohos.application.Ability'
|
||||
|
||||
export default class MainAbility extends Ability {
|
||||
onCreate(want, launchParam) {
|
||||
console.log("MainAbility onCreate, launchReason is " + launchParam.launchReason)
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
console.log("MainAbility onDestroy")
|
||||
}
|
||||
|
||||
onWindowStageCreate(windowStage) {
|
||||
console.log("MainAbility onWindowStageCreate")
|
||||
windowStage.setUIContent(this.context, "pages/MyNoteHome", null)
|
||||
}
|
||||
|
||||
onWindowStageDestroy() {
|
||||
console.log("MainAbility onWindowStageDestroy")
|
||||
}
|
||||
|
||||
onForeground() {
|
||||
console.log("MainAbility onForeground")
|
||||
}
|
||||
|
||||
onBackground() {
|
||||
console.log("MainAbility onBackground")
|
||||
}
|
||||
};
|
@ -36,9 +36,8 @@ export struct NoteHomeComp {
|
||||
// 当前文件夹、笔记、分栏
|
||||
@Provide('SelectedFolderData') selectedFolderData: FolderData = AppStorage.Get('Folder')
|
||||
@Provide('SelectedNoteData') selectedNoteData: NoteData = AppStorage.Get('Note')
|
||||
@Provide('SectionStatus') sectionStatus: number = AppStorage.Get('Section');
|
||||
|
||||
@Provide('SelectedColor') selectedColor: string = circleColorArray[0];
|
||||
@Provide('SectionStatus') sectionStatus: number = AppStorage.Get('Section')
|
||||
@Provide('SelectedColor') selectedColor: string = circleColorArray[0]
|
||||
@Provide('Longpress') longpress: boolean = false // 第二栏长按状态
|
||||
@Provide('ExpandStatus') expandStatus: boolean = false // 笔记本折叠展开状态
|
||||
@Provide('ChooseNote') chooseNote: boolean = true // 是否选择笔记进行打开
|
||||
@ -80,7 +79,8 @@ export struct NoteHomeComp {
|
||||
.height(StyleConstants.PERCENTAGE_100)
|
||||
.visibility(
|
||||
LayoutUtil.getWidthWeightMessage(this.sectionStatus)
|
||||
.noteListVisibility == 0 ? Visibility.None : Visibility.Visible);
|
||||
.noteListVisibility == 0 ? Visibility.None : Visibility.Visible)
|
||||
|
||||
Divider()
|
||||
.vertical(true)
|
||||
.strokeWidth(1)
|
||||
|
@ -15,12 +15,15 @@
|
||||
|
||||
import {FolderListComp} from '../../../../../../../common/component/src/main/ets/default/FolderListComp.ets'
|
||||
import {NoteListComp} from '../../../../../../../common/component/src/main/ets/default/NoteListComp.ets'
|
||||
import {NoteContentComp} from '../../../../../../../common/component/src/main/ets/default/NoteContentComp'
|
||||
import {NoteContentCompPortrait} from '../../../../../../../common/component/src/main/ets/default/NoteContentCompPortrait.ets'
|
||||
import StyleConstants from '../../../../../../../common/utils/src/main/ets/default/constants/StyleConstants.ets'
|
||||
import LogUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'
|
||||
import {circleColorArray} from '../../../../../../../common/utils/src/main/ets/default/model/NoteBaseData.ets'
|
||||
import FolderData from '../../../../../../../common/utils/src/main/ets/default/model/databaseModel/FolderData.ets'
|
||||
import NoteData from '../../../../../../../common/utils/src/main/ets/default/model/databaseModel/NoteData.ets'
|
||||
import {SysDefFolderUuid} from '../../../../../../../common/utils/src/main/ets/default/model/databaseModel/EnumData.ets'
|
||||
import LayoutUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LayoutUtil.ets'
|
||||
import NoteUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/NoteUtil.ets'
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
@ -30,11 +33,12 @@ export struct NoteHomePortraitComp {
|
||||
@StorageLink('AllFolderArray') AllFolderArray: FolderData[] = AppStorage.Link('AllFolderArray')
|
||||
@StorageLink('CheckedNoteArray') CheckedNoteArray: NoteData[] = []
|
||||
|
||||
|
||||
// 当前文件夹、笔记、分栏
|
||||
@Provide('SelectedFolderData') selectedFolderData: FolderData = AppStorage.Get('Folder')
|
||||
@Provide('SelectedNoteData') selectedNoteData: NoteData = AppStorage.Get('Note')
|
||||
@Provide('SectionStatus') sectionStatus: number = AppStorage.Get('Section');
|
||||
|
||||
@Provide('SectionStatus') sectionStatus: number = 1; // 表示分栏状态, 3表示三分栏, 2表示二分栏,1表示一分栏
|
||||
@Provide('LastSectionStatus') lastSectionStatus: number = 1; // 记录分栏上一次的状态
|
||||
@Provide('SelectedColor') selectedColor: string = circleColorArray[0];
|
||||
@Provide('Longpress') longpress: boolean = false // 第二栏长按状态
|
||||
@Provide('ExpandStatus') expandStatus: boolean = false // 笔记本折叠展开状态
|
||||
@ -42,6 +46,8 @@ export struct NoteHomePortraitComp {
|
||||
@Provide('Search') search: boolean = false // 是否处于搜索状态
|
||||
@Provide('SearchResultList') searchResultList: NoteData[] = [] // 搜索得到的笔记列表
|
||||
@Provide('InputKeyword') inputKeyword: string = '' // 搜索的字串
|
||||
@Provide('SelectedAll') selectedAll:boolean = false;
|
||||
@Provide('EditModel') editModel: boolean = false
|
||||
|
||||
TAG = "NoteHomeComp"
|
||||
|
||||
@ -67,13 +73,14 @@ export struct NoteHomePortraitComp {
|
||||
|
||||
|
||||
// Note content display area
|
||||
if(this.chooseNote == true ) {
|
||||
Flex({ direction: FlexDirection.Column, wrap: FlexWrap.Wrap, justifyContent: FlexAlign.Start }) {
|
||||
NoteContentComp()
|
||||
NoteContentCompPortrait()
|
||||
}
|
||||
.backgroundColor($r("app.color.notecontent_color_ffffff"))
|
||||
.width(StyleConstants.PERCENTAGE_100)
|
||||
.height(StyleConstants.PERCENTAGE_100)
|
||||
.visibility(this.chooseNote == false ? Visibility.None:Visibility.Visible)
|
||||
}
|
||||
}
|
||||
.width(StyleConstants.PERCENTAGE_100).height(StyleConstants.PERCENTAGE_100)
|
||||
}
|
||||
|
Before Width: | Height: | Size: 172 KiB After Width: | Height: | Size: 1.3 MiB |
@ -87,6 +87,10 @@
|
||||
{
|
||||
"name": "button_color_f86d05",
|
||||
"value": "#f86d05"
|
||||
},
|
||||
{
|
||||
"name": "font_stylecolor_AD182431",
|
||||
"value": "#AD182431"
|
||||
}
|
||||
]
|
||||
}
|
@ -139,6 +139,30 @@
|
||||
{
|
||||
"name": "editNoteTitle",
|
||||
"value": "修改标题"
|
||||
},
|
||||
{
|
||||
"name": "list",
|
||||
"value": "清单"
|
||||
},
|
||||
{
|
||||
"name": "style",
|
||||
"value": "样式"
|
||||
},
|
||||
{
|
||||
"name": "photo",
|
||||
"value": "相册"
|
||||
},
|
||||
{
|
||||
"name": "title",
|
||||
"value": "标题"
|
||||
},
|
||||
{
|
||||
"name": "empty_note",
|
||||
"value": "笔记内容为空"
|
||||
},
|
||||
{
|
||||
"name": "restore",
|
||||
"value": "已恢复"
|
||||
}
|
||||
]
|
||||
}
|
BIN
product/phone/src/main/resources/rawfile/cake.png
Normal file
After Width: | Height: | Size: 1.3 MiB |
27
product/phone/src/main/resources/rawfile/editor.html
Normal file
@ -0,0 +1,27 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
"editorJs"
|
||||
</title>
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=640, user-scalable=no, target-densitydpi=device-dpi">
|
||||
<meta
|
||||
http-equiv="Content-Type"
|
||||
content="text/html; charset=UTF-8">
|
||||
<link
|
||||
rel="stylesheet"
|
||||
type="text/css"
|
||||
href="editor_style.css">
|
||||
</head>
|
||||
<body onload="load()">
|
||||
<div
|
||||
id="editorjs"
|
||||
contenteditable="true">
|
||||
</div>
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="rich_editor.js"></script>
|
||||
</body>
|
||||
</html>
|
89
product/phone/src/main/resources/rawfile/editor_style.css
Normal file
@ -0,0 +1,89 @@
|
||||
/**
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
html {
|
||||
height: 100%;
|
||||
font-family: sans-serif;
|
||||
-webkit-text-size-adjust: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
overflow: scroll;
|
||||
display: table;
|
||||
table-layout: fixed;
|
||||
width: 100%;
|
||||
min-height:100%;
|
||||
color: #333333;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#editorjs {
|
||||
padding-left: 24px;
|
||||
padding-right: 24px;
|
||||
width:100%;
|
||||
display: table-cell;
|
||||
outline: 0px solid transparent;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
background-size: cover;
|
||||
color: #333333;
|
||||
font-size:40px;
|
||||
}
|
||||
|
||||
#editorjs[placeholder]:empty:not(:focus):before {
|
||||
content: attr(placeholder);
|
||||
font-size:40px;
|
||||
color: #9b9b9b;
|
||||
}
|
||||
|
||||
.note-checkbox:checked {
|
||||
background: #F88805;
|
||||
border: 2px solid #F88805;
|
||||
outline: none;
|
||||
margin-left:0px;
|
||||
margin-right:0px;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.note-checkbox {
|
||||
width: 23px;
|
||||
height: 23px;
|
||||
background-color: #ffffff;
|
||||
border: 2px solid #555555;
|
||||
-webkit-border-radius: 50%;
|
||||
-webkit-appearance: none;
|
||||
-webkit-user-select: none;
|
||||
border-radius: 50%;
|
||||
font-size: 0.8rem;
|
||||
margin-left:0px;
|
||||
margin-top:10px;
|
||||
margin-right:0px;
|
||||
margin-bottom:0px;
|
||||
outline: none;
|
||||
padding: 0;
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
-webkit-transition: background-color ease 0.1s;
|
||||
transition: background-color ease 0.1s;
|
||||
vertical-align: top;
|
||||
cursor: default;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.note-checkbox:checked+span{
|
||||
text-decoration: line-through;
|
||||
color:#F88805;
|
||||
opacity: 0.4;
|
||||
}
|
BIN
product/phone/src/main/resources/rawfile/lvyou.png
Normal file
After Width: | Height: | Size: 1.1 MiB |
306
product/phone/src/main/resources/rawfile/rich_editor.js
Normal file
@ -0,0 +1,306 @@
|
||||
/**
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
var RICH_EDITOR = {};
|
||||
|
||||
RICH_EDITOR.editor = document.getElementById('editorjs');
|
||||
|
||||
RICH_EDITOR.setHtml = function(contents) {
|
||||
RICH_EDITOR.editor.innerHTML = decodeURIComponent(contents.replace(/\+/g, '%20'));
|
||||
}
|
||||
|
||||
RICH_EDITOR.getHtml = function() {
|
||||
return RICH_EDITOR.editor.innerHTML;
|
||||
}
|
||||
|
||||
RICH_EDITOR.getText = function() {
|
||||
console.log(RICH_EDITOR.editor.innerText);
|
||||
return RICH_EDITOR.editor.innerText;
|
||||
}
|
||||
|
||||
RICH_EDITOR.setBaseTextColor = function(color) {
|
||||
RICH_EDITOR.editor.style.color = color;
|
||||
}
|
||||
|
||||
RICH_EDITOR.setBaseFontSize = function(size) {
|
||||
RICH_EDITOR.editor.style.fontSize = size;
|
||||
}
|
||||
|
||||
RICH_EDITOR.undo = function() {
|
||||
document.execCommand('undo', false, null);
|
||||
}
|
||||
|
||||
RICH_EDITOR.redo = function() {
|
||||
document.execCommand('redo', false, null);
|
||||
}
|
||||
|
||||
RICH_EDITOR.setBold = function() {
|
||||
document.execCommand('bold');
|
||||
}
|
||||
|
||||
RICH_EDITOR.setItalic = function() {
|
||||
document.execCommand('italic', false, null);
|
||||
}
|
||||
|
||||
RICH_EDITOR.setSubscript = function() {
|
||||
document.execCommand('subscript', false, null);
|
||||
}
|
||||
|
||||
RICH_EDITOR.setSuperscript = function() {
|
||||
document.execCommand('superscript', false, null);
|
||||
}
|
||||
|
||||
RICH_EDITOR.setStrikeThrough = function() {
|
||||
document.execCommand('strikeThrough', false, null);
|
||||
}
|
||||
|
||||
RICH_EDITOR.setUnderline = function() {
|
||||
document.execCommand('underline', false, null);
|
||||
}
|
||||
|
||||
RICH_EDITOR.setNumbers = function () {
|
||||
document.execCommand('insertOrderedList', false, null);
|
||||
var selection, type;
|
||||
if (window.getSelection) {
|
||||
selection = getSelection();
|
||||
}
|
||||
if (selection) {
|
||||
var range = selection.getRangeAt ? selection.getRangeAt(0) : selection.createRange();
|
||||
try {
|
||||
var child = range.commonAncestorContainer.parentNode;
|
||||
for (var i = 0; i < 10; i++) {
|
||||
if (child.nodeName == "OL") {
|
||||
child.style["list-style"] = "decimal";
|
||||
break;
|
||||
}
|
||||
if (child.parentNode) {
|
||||
child = child.parentNode
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RICH_EDITOR.setABC = function () {
|
||||
document.execCommand('insertOrderedList', false, null);
|
||||
var selection, type;
|
||||
if (window.getSelection) {
|
||||
selection = getSelection();
|
||||
}
|
||||
if (selection) {
|
||||
var range = selection.getRangeAt ? selection.getRangeAt(0) : selection.createRange();
|
||||
try {
|
||||
var child = range.commonAncestorContainer.parentNode;
|
||||
for (var i = 0; i < 10; i++) {
|
||||
if (child.nodeName == "OL") {
|
||||
child.style["list-style"] = "lower-alpha";
|
||||
break;
|
||||
}
|
||||
if (child.parentNode) {
|
||||
child = child.parentNode
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RICH_EDITOR.setBullets = function () {
|
||||
document.execCommand('insertUnorderedList', false, null);
|
||||
var selection, type;
|
||||
if (window.getSelection) {
|
||||
selection = getSelection();
|
||||
}
|
||||
if (selection) {
|
||||
var range = selection.getRangeAt ? selection.getRangeAt(0) : selection.createRange();
|
||||
try {
|
||||
var child = range.commonAncestorContainer.parentNode;
|
||||
for (var i = 0; i < 10; i++) {
|
||||
if (child.nodeName == "UL") {
|
||||
child.style["list-style"] = "disc";
|
||||
break;
|
||||
}
|
||||
if (child.parentNode) {
|
||||
child = child.parentNode
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RICH_EDITOR.setSquare = function () {
|
||||
document.execCommand('insertUnorderedList', false, null);
|
||||
var selection, type;
|
||||
if (window.getSelection) {
|
||||
selection = getSelection();
|
||||
}
|
||||
if (selection) {
|
||||
var range = selection.getRangeAt ? selection.getRangeAt(0) : selection.createRange();
|
||||
try {
|
||||
var child = range.commonAncestorContainer.parentNode;
|
||||
for (var i = 0; i < 10; i++) {
|
||||
if (child.nodeName == "UL") {
|
||||
child.style["list-style"] = "square";
|
||||
break;
|
||||
}
|
||||
if (child.parentNode) {
|
||||
child = child.parentNode
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RICH_EDITOR.setTextColor = function (color) {
|
||||
document.execCommand('foreColor', false, color);
|
||||
}
|
||||
|
||||
RICH_EDITOR.setTextBackgroundColor = function(color) {
|
||||
RICH_EDITOR.restorerange();
|
||||
document.execCommand("styleWithCSS", null, true);
|
||||
document.execCommand('hiliteColor', false, color);
|
||||
document.execCommand("styleWithCSS", null, false);
|
||||
}
|
||||
|
||||
RICH_EDITOR.setFontSize = function(fontSize){
|
||||
document.execCommand("fontSize", false, fontSize);
|
||||
}
|
||||
|
||||
RICH_EDITOR.execFontSize = function (size, unit) {
|
||||
document.execCommand("fontSize", false, "7");
|
||||
var fontElements = window.getSelection().anchorNode.parentNode
|
||||
fontElements.removeAttribute("size");
|
||||
fontElements.style.fontSize = size + 'px'
|
||||
};
|
||||
|
||||
RICH_EDITOR.setHeading = function(heading) {
|
||||
document.execCommand('formatBlock', false, '<h'+heading+'>');
|
||||
}
|
||||
|
||||
RICH_EDITOR.setIndent = function() {
|
||||
document.execCommand('indent', false, null);
|
||||
}
|
||||
|
||||
RICH_EDITOR.setOutdent = function() {
|
||||
document.execCommand('outdent', false, null);
|
||||
}
|
||||
|
||||
RICH_EDITOR.setJustifyLeft = function() {
|
||||
document.execCommand('justifyLeft', false, null);
|
||||
}
|
||||
|
||||
RICH_EDITOR.setJustifyCenter = function() {
|
||||
document.execCommand('justifyCenter', false, null);
|
||||
}
|
||||
|
||||
RICH_EDITOR.setJustifyRight = function() {
|
||||
document.execCommand('justifyRight', false, null);
|
||||
}
|
||||
|
||||
RICH_EDITOR.setBlockquote = function() {
|
||||
document.execCommand('formatBlock', false, '<blockquote>');
|
||||
}
|
||||
|
||||
RICH_EDITOR.insertImage = function() {
|
||||
var url = './shuxue.png';
|
||||
var html = '<br></br><img src="' + url + '" alt="picvision" style="margin:0px auto;width:90%;display:table-cell;vertical-align:middle;border-radius:10px;max-width:90%" /><br></br>';
|
||||
RICH_EDITOR.insertHTML(html);
|
||||
RICH_EDITOR.editor.scrollIntoView(false)
|
||||
}
|
||||
|
||||
RICH_EDITOR.insertHTML = function(html) {
|
||||
RICH_EDITOR.restorerange();
|
||||
document.execCommand('insertHTML', false, html);
|
||||
}
|
||||
|
||||
RICH_EDITOR.setDone = function() {
|
||||
var html = '<input type="checkbox" checked="checked"/> ';
|
||||
document.execCommand('insertHTML', false, html);
|
||||
}
|
||||
|
||||
RICH_EDITOR.addTodo=function(e){
|
||||
KEY_ENTER=13;
|
||||
if(e.which == KEY_ENTER){
|
||||
var node=RICH_EDITOR.getSelectedAnchorNode();
|
||||
if(node&&node.nodeName=="#text"){
|
||||
node=node.parentElement;
|
||||
}
|
||||
if(node&&node.nodeName=="SPAN"&&node.previousElementSibling&&node.previousElementSibling.className=='note-checkbox'){
|
||||
RICH_EDITOR.setTodo();
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RICH_EDITOR.setTodo = function () {
|
||||
var parent = document.getElementById('editorjs')
|
||||
var isContentEmpty = parent.innerHTML.trim().length == 0 || parent.innerHTML == '<br>';
|
||||
var html = (isContentEmpty ? '' : '<br/>') + '<input name="checkbox" type="checkbox" onclick="onCheckChange(this)" class="note-checkbox"><span class="note-checkbox-txt"> </span>';
|
||||
document.execCommand('insertHTML', false, html);
|
||||
}
|
||||
|
||||
function onCheckChange(checkbox) {
|
||||
if (checkbox.checked == true) {
|
||||
checkbox.setAttribute("checked", "checked");
|
||||
} else {
|
||||
checkbox.removeAttribute("checked");
|
||||
}
|
||||
}
|
||||
|
||||
RICH_EDITOR.restorerange = function(){
|
||||
var selection = window.getSelection();
|
||||
selection.removeAllRanges();
|
||||
var range = document.createRange();
|
||||
range.setStart(RICH_EDITOR.currentSelection.startContainer, RICH_EDITOR.currentSelection.startOffset);
|
||||
range.setEnd(RICH_EDITOR.currentSelection.endContainer, RICH_EDITOR.currentSelection.endOffset);
|
||||
selection.addRange(range);
|
||||
}
|
||||
|
||||
//获取光标开始位置归属节点
|
||||
RICH_EDITOR.getSelectedAnchorNode=function(){
|
||||
var node,selection;
|
||||
if (window.getSelection) {
|
||||
selection = getSelection();
|
||||
node = selection.anchorNode;
|
||||
}
|
||||
if (!node && document.selection) {
|
||||
selection = document.selection
|
||||
var range = selection.getRangeAt ? selection.getRangeAt(0) : selection.createRange();
|
||||
node = range.commonAncestorContainer ? range.commonAncestorContainer :
|
||||
range.parentElement ? range.parentElement() : range.item(0);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
function get_html_content() {
|
||||
console.log('hhh Ark WebComponent');
|
||||
var htmlString = encodeURI(RICH_EDITOR.getHtml())
|
||||
var str = callBackToApp.callbackhtml(htmlString)
|
||||
console.log('hhh objName.test result:' + str);
|
||||
}
|
||||
|
||||
function save_html_content() {
|
||||
console.log('hhh Ark WebComponent');
|
||||
var htmlString = encodeURI(RICH_EDITOR.getHtml())
|
||||
var str = callBackToApp.callbackhtmlSave(htmlString)
|
||||
console.log('hhh objName.test result:' + str);
|
||||
}
|
BIN
product/phone/src/main/resources/rawfile/shuxue.png
Normal file
After Width: | Height: | Size: 280 KiB |
@ -39,7 +39,7 @@
|
||||
"description": "$string:description_mainability",
|
||||
"label": "$string:entry_MainAbility",
|
||||
"type": "page",
|
||||
"launchType": "singleton",
|
||||
"launchType": "standard",
|
||||
"srcPath": "MainAbility",
|
||||
"srcLanguage": "ets",
|
||||
"metaData": {
|
||||
|
@ -1,18 +1,3 @@
|
||||
/**
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
import AbilityStage from "@ohos.application.AbilityStage"
|
||||
|
||||
export default class MyAbilityStage extends AbilityStage {
|
||||
|
@ -1,19 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
import Ability from '@ohos.application.Ability'
|
||||
import {WebViewUtil} from './WebViewUtil.ets'
|
||||
|
||||
export default class MainAbility extends Ability {
|
||||
onCreate(want, launchParam) {
|
||||
@ -23,16 +9,13 @@ export default class MainAbility extends Ability {
|
||||
let continueFolder: string = want.parameters["ContinueFolder"]
|
||||
let continueNote: string = want.parameters["ContinueNote"]
|
||||
let continueSection: number = want.parameters["ContinueSection"]
|
||||
console.log("MainAbility launchReason = 3, continueFolder is " + continueFolder)
|
||||
console.log("MainAbility launchReason = 3, continueNote is " + continueNote)
|
||||
console.log("MainAbility launchReason = 3, continueSection is " + continueSection)
|
||||
// 迁移数据存入AppStorage
|
||||
AppStorage.SetOrCreate<string>('ContinueFolder', continueFolder)
|
||||
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
|
||||
AppStorage.SetOrCreate<number>('ContinueSection', continueSection)
|
||||
// 设置迁移标记
|
||||
AppStorage.SetOrCreate<number>('IsContinue', 1)
|
||||
this.context.restoreWindowStage(null);
|
||||
this.context.restoreWindowStage(null)
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,37 +38,42 @@ export default class MainAbility extends Ability {
|
||||
|
||||
onBackground() {
|
||||
console.log("MainAbility onBackground")
|
||||
let controllerShow = WebViewUtil.getWebController()
|
||||
if (controllerShow == undefined || controllerShow == null) {
|
||||
console.info("MainAbility onBackground, controllerShow is error")
|
||||
}
|
||||
console.log("MainAbility controllerShow : " + controllerShow)
|
||||
controllerShow.runJavaScript({
|
||||
script: "get_html_content()"
|
||||
})
|
||||
console.log("MainAbility controllerShow end")
|
||||
}
|
||||
|
||||
onContinue(wantParam: { [key: string]: any }) {
|
||||
console.log("MainAbility onContinue")
|
||||
|
||||
// 获取本端的迁移数据
|
||||
let continueFolder = AppStorage.Get<string>('ContinueFolder')
|
||||
if (continueFolder == undefined || continueFolder == null) {
|
||||
console.log("MainAbility onContinue, continue first folder")
|
||||
continueFolder = JSON.stringify(AppStorage.Get('AllFolderArray')[0].toFolderObject())
|
||||
}
|
||||
console.log("MainAbility onContinue, continueFolder is " + continueFolder)
|
||||
|
||||
let continueNote = AppStorage.Get<string>('ContinueNote')
|
||||
if (continueNote == undefined || continueNote == null) {
|
||||
console.log("MainAbility onContinue, continue first note")
|
||||
continueNote = JSON.stringify(AppStorage.Get('AllNoteArray')[0].toNoteObject())
|
||||
}
|
||||
console.log("MainAbility onContinue, continueNote is " + continueNote)
|
||||
|
||||
let continueSection = AppStorage.Get<number>('ContinueSection')
|
||||
if (continueSection == undefined || continueSection == null) {
|
||||
console.log("MainAbility onContinue, continue section 3")
|
||||
continueSection = 3
|
||||
}
|
||||
console.log("MainAbility onContinue, continueSection is " + continueSection)
|
||||
|
||||
// 保存本端的迁移数据
|
||||
wantParam["ContinueFolder"] = continueFolder;
|
||||
wantParam["ContinueNote"] = continueNote;
|
||||
wantParam["ContinueSection"] = continueSection;
|
||||
wantParam["ContinueFolder"] = continueFolder
|
||||
wantParam["ContinueNote"] = continueNote
|
||||
wantParam["ContinueSection"] = continueSection
|
||||
|
||||
return true
|
||||
}
|
||||
|
35
product/tablet/src/main/ets/MainAbility/WebViewUtil.ets
Normal file
@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Copyright (c) 2022 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* WebView Util
|
||||
*/
|
||||
export class WebViewUtil {
|
||||
private static controllerShow: WebController
|
||||
|
||||
private constructor() {
|
||||
|
||||
}
|
||||
|
||||
public static getWebController(): WebController{
|
||||
console.info('WebViewUtil, getWebController')
|
||||
if (!this.controllerShow) {
|
||||
console.info('WebViewUtil, controllerShow is null')
|
||||
this.controllerShow = new WebController()
|
||||
}
|
||||
return this.controllerShow
|
||||
}
|
||||
|
||||
}
|
@ -37,7 +37,8 @@ export struct MyNoteHomeComp {
|
||||
}
|
||||
}
|
||||
}
|
||||
.width('100%').height('100%')
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
}
|
||||
|
||||
aboutToAppear(): void{
|
||||
|
@ -24,6 +24,7 @@ import NoteData from '../../../../../../../common/utils/src/main/ets/default/mod
|
||||
import {SysDefFolderUuid} from '../../../../../../../common/utils/src/main/ets/default/model/databaseModel/EnumData.ets'
|
||||
import LayoutUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LayoutUtil.ets'
|
||||
import NoteUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/NoteUtil.ets'
|
||||
import {WebViewUtil} from '../../../../../../../common/utils/src/main/ets/default/baseUtil/WebViewUtil.ets'
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
@ -36,19 +37,18 @@ export struct NoteHomeComp {
|
||||
// 当前文件夹、笔记、分栏
|
||||
@Provide('SelectedFolderData') selectedFolderData: FolderData = AppStorage.Get('Folder')
|
||||
@Provide('SelectedNoteData') selectedNoteData: NoteData = AppStorage.Get('Note')
|
||||
@Provide('SectionStatus') sectionStatus: number = AppStorage.Get('Section');
|
||||
|
||||
@Provide('SelectedColor') selectedColor: string = circleColorArray[0];
|
||||
@Provide('LastSectionStatus') lastSectionStatus: number = 3; // 记录分栏上一次的状态
|
||||
@Provide('SectionStatus') sectionStatus: number = AppStorage.Get('Section')
|
||||
@Provide('SelectedColor') selectedColor: string = circleColorArray[0]
|
||||
@Provide('LastSectionStatus') lastSectionStatus: number = 3 // 记录分栏上一次的状态
|
||||
@Provide('Longpress') longpress: boolean = false // 第二栏长按状态
|
||||
@Provide('ExpandStatus') expandStatus: boolean = false // 笔记本折叠展开状态
|
||||
@Provide('ChooseNote') chooseNote: boolean = true // 是否选择笔记进行打开
|
||||
@Provide('Search') search: boolean = false // 是否处于搜索状态
|
||||
@Provide('SearchResultList') searchResultList: NoteData[] = [] // 搜索得到的笔记列表
|
||||
@Provide('InputKeyword') inputKeyword: string = '' // 搜索的字串
|
||||
@Provide('SelectedAll') selectedAll: boolean = false;
|
||||
@Provide('SelectedAll') selectedAll: boolean = false
|
||||
@Provide('EditModel') editModel: boolean = false //编辑模式:临时方案
|
||||
private controllerShow: WebController = new WebController() //第三栏展示
|
||||
private controllerShow: WebController = WebViewUtil.getWebController() //第三栏展示
|
||||
|
||||
TAG = "NoteHomeComp"
|
||||
|
||||
@ -84,7 +84,8 @@ export struct NoteHomeComp {
|
||||
.height(StyleConstants.PERCENTAGE_100)
|
||||
.visibility(
|
||||
LayoutUtil.getWidthWeightMessage(this.sectionStatus)
|
||||
.noteListVisibility == 0 ? Visibility.None : Visibility.Visible);
|
||||
.noteListVisibility == 0 ? Visibility.None : Visibility.Visible)
|
||||
|
||||
Divider()
|
||||
.vertical(true)
|
||||
.strokeWidth(1)
|
||||
@ -102,7 +103,8 @@ export struct NoteHomeComp {
|
||||
.opacity(this.longpress ? StyleConstants.OPACITY_40 : this.search && this.inputKeyword.length == 0 ? StyleConstants.OPACITY_20 : StyleConstants.OPACITY_100)
|
||||
.enabled(this.longpress || this.search && this.inputKeyword.length == 0 ? false : true)
|
||||
}
|
||||
.width(StyleConstants.PERCENTAGE_100).height(StyleConstants.PERCENTAGE_100)
|
||||
.width(StyleConstants.PERCENTAGE_100)
|
||||
.height(StyleConstants.PERCENTAGE_100)
|
||||
}
|
||||
|
||||
aboutToAppear(): void{
|
||||
|
@ -33,9 +33,8 @@ export struct NoteHomePortraitComp {
|
||||
// 当前文件夹、笔记、分栏
|
||||
@Provide('SelectedFolderData') selectedFolderData: FolderData = AppStorage.Get('Folder')
|
||||
@Provide('SelectedNoteData') selectedNoteData: NoteData = AppStorage.Get('Note')
|
||||
@Provide('SectionStatus') sectionStatus: number = AppStorage.Get('Section');
|
||||
|
||||
@Provide('SelectedColor') selectedColor: string = circleColorArray[0];
|
||||
@Provide('SectionStatus') sectionStatus: number = AppStorage.Get('Section')
|
||||
@Provide('SelectedColor') selectedColor: string = circleColorArray[0]
|
||||
@Provide('Longpress') longpress: boolean = false // 第二栏长按状态
|
||||
@Provide('ExpandStatus') expandStatus: boolean = false // 笔记本折叠展开状态
|
||||
@Provide('ChooseNote') chooseNote: boolean = true // 是否选择笔记进行打开
|
||||
@ -75,7 +74,8 @@ export struct NoteHomePortraitComp {
|
||||
.height(StyleConstants.PERCENTAGE_100)
|
||||
.visibility(this.chooseNote == false ? Visibility.None : Visibility.Visible)
|
||||
}
|
||||
.width(StyleConstants.PERCENTAGE_100).height(StyleConstants.PERCENTAGE_100)
|
||||
.width(StyleConstants.PERCENTAGE_100)
|
||||
.height(StyleConstants.PERCENTAGE_100)
|
||||
}
|
||||
|
||||
aboutToAppear(): void{
|
||||
|
Before Width: | Height: | Size: 172 KiB After Width: | Height: | Size: 1.3 MiB |
@ -87,6 +87,10 @@
|
||||
{
|
||||
"name": "button_color_f86d05",
|
||||
"value": "#f86d05"
|
||||
},
|
||||
{
|
||||
"name": "font_stylecolor_AD182431",
|
||||
"value": "#AD182431"
|
||||
}
|
||||
]
|
||||
}
|
@ -139,6 +139,30 @@
|
||||
{
|
||||
"name": "editNoteTitle",
|
||||
"value": "修改标题"
|
||||
},
|
||||
{
|
||||
"name": "list",
|
||||
"value": "清单"
|
||||
},
|
||||
{
|
||||
"name": "style",
|
||||
"value": "样式"
|
||||
},
|
||||
{
|
||||
"name": "photo",
|
||||
"value": "相册"
|
||||
},
|
||||
{
|
||||
"name": "title",
|
||||
"value": "标题"
|
||||
},
|
||||
{
|
||||
"name": "empty_note",
|
||||
"value": "笔记内容为空"
|
||||
},
|
||||
{
|
||||
"name": "restore",
|
||||
"value": "已恢复"
|
||||
}
|
||||
]
|
||||
}
|
Before Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 172 KiB After Width: | Height: | Size: 1.3 MiB |
27
product/tablet/src/main/resources/rawfile/editor.html
Normal file
@ -0,0 +1,27 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
"editorJs"
|
||||
</title>
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=640, user-scalable=no, target-densitydpi=device-dpi">
|
||||
<meta
|
||||
http-equiv="Content-Type"
|
||||
content="text/html; charset=UTF-8">
|
||||
<link
|
||||
rel="stylesheet"
|
||||
type="text/css"
|
||||
href="editor_style.css">
|
||||
</head>
|
||||
<body onload="load()">
|
||||
<div
|
||||
id="editorjs"
|
||||
contenteditable="true">
|
||||
</div>
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="rich_editor.js"></script>
|
||||
</body>
|
||||
</html>
|
89
product/tablet/src/main/resources/rawfile/editor_style.css
Normal file
@ -0,0 +1,89 @@
|
||||
/**
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
html {
|
||||
height: 100%;
|
||||
font-family: sans-serif;
|
||||
-webkit-text-size-adjust: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
overflow: scroll;
|
||||
display: table;
|
||||
table-layout: fixed;
|
||||
width: 100%;
|
||||
min-height:100%;
|
||||
color: #333333;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#editorjs {
|
||||
padding-left: 24px;
|
||||
padding-right: 24px;
|
||||
width:100%;
|
||||
display: table-cell;
|
||||
outline: 0px solid transparent;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
background-size: cover;
|
||||
color: #333333;
|
||||
font-size:40px;
|
||||
}
|
||||
|
||||
#editorjs[placeholder]:empty:not(:focus):before {
|
||||
content: attr(placeholder);
|
||||
font-size:40px;
|
||||
color: #9b9b9b;
|
||||
}
|
||||
|
||||
.note-checkbox:checked {
|
||||
background: #F88805;
|
||||
border: 2px solid #F88805;
|
||||
outline: none;
|
||||
margin-left:0px;
|
||||
margin-right:0px;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.note-checkbox {
|
||||
width: 23px;
|
||||
height: 23px;
|
||||
background-color: #ffffff;
|
||||
border: 2px solid #555555;
|
||||
-webkit-border-radius: 50%;
|
||||
-webkit-appearance: none;
|
||||
-webkit-user-select: none;
|
||||
border-radius: 50%;
|
||||
font-size: 0.8rem;
|
||||
margin-left:0px;
|
||||
margin-top:10px;
|
||||
margin-right:0px;
|
||||
margin-bottom:0px;
|
||||
outline: none;
|
||||
padding: 0;
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
-webkit-transition: background-color ease 0.1s;
|
||||
transition: background-color ease 0.1s;
|
||||
vertical-align: top;
|
||||
cursor: default;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.note-checkbox:checked+span{
|
||||
text-decoration: line-through;
|
||||
color:#F88805;
|
||||
opacity: 0.4;
|
||||
}
|
306
product/tablet/src/main/resources/rawfile/rich_editor.js
Normal file
@ -0,0 +1,306 @@
|
||||
/**
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
var RICH_EDITOR = {};
|
||||
|
||||
RICH_EDITOR.editor = document.getElementById('editorjs');
|
||||
|
||||
RICH_EDITOR.setHtml = function(contents) {
|
||||
RICH_EDITOR.editor.innerHTML = decodeURIComponent(contents.replace(/\+/g, '%20'));
|
||||
}
|
||||
|
||||
RICH_EDITOR.getHtml = function() {
|
||||
return RICH_EDITOR.editor.innerHTML;
|
||||
}
|
||||
|
||||
RICH_EDITOR.getText = function() {
|
||||
console.log(RICH_EDITOR.editor.innerText);
|
||||
return RICH_EDITOR.editor.innerText;
|
||||
}
|
||||
|
||||
RICH_EDITOR.setBaseTextColor = function(color) {
|
||||
RICH_EDITOR.editor.style.color = color;
|
||||
}
|
||||
|
||||
RICH_EDITOR.setBaseFontSize = function(size) {
|
||||
RICH_EDITOR.editor.style.fontSize = size;
|
||||
}
|
||||
|
||||
RICH_EDITOR.undo = function() {
|
||||
document.execCommand('undo', false, null);
|
||||
}
|
||||
|
||||
RICH_EDITOR.redo = function() {
|
||||
document.execCommand('redo', false, null);
|
||||
}
|
||||
|
||||
RICH_EDITOR.setBold = function() {
|
||||
document.execCommand('bold');
|
||||
}
|
||||
|
||||
RICH_EDITOR.setItalic = function() {
|
||||
document.execCommand('italic', false, null);
|
||||
}
|
||||
|
||||
RICH_EDITOR.setSubscript = function() {
|
||||
document.execCommand('subscript', false, null);
|
||||
}
|
||||
|
||||
RICH_EDITOR.setSuperscript = function() {
|
||||
document.execCommand('superscript', false, null);
|
||||
}
|
||||
|
||||
RICH_EDITOR.setStrikeThrough = function() {
|
||||
document.execCommand('strikeThrough', false, null);
|
||||
}
|
||||
|
||||
RICH_EDITOR.setUnderline = function() {
|
||||
document.execCommand('underline', false, null);
|
||||
}
|
||||
|
||||
RICH_EDITOR.setNumbers = function () {
|
||||
document.execCommand('insertOrderedList', false, null);
|
||||
var selection, type;
|
||||
if (window.getSelection) {
|
||||
selection = getSelection();
|
||||
}
|
||||
if (selection) {
|
||||
var range = selection.getRangeAt ? selection.getRangeAt(0) : selection.createRange();
|
||||
try {
|
||||
var child = range.commonAncestorContainer.parentNode;
|
||||
for (var i = 0; i < 10; i++) {
|
||||
if (child.nodeName == "OL") {
|
||||
child.style["list-style"] = "decimal";
|
||||
break;
|
||||
}
|
||||
if (child.parentNode) {
|
||||
child = child.parentNode
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RICH_EDITOR.setABC = function () {
|
||||
document.execCommand('insertOrderedList', false, null);
|
||||
var selection, type;
|
||||
if (window.getSelection) {
|
||||
selection = getSelection();
|
||||
}
|
||||
if (selection) {
|
||||
var range = selection.getRangeAt ? selection.getRangeAt(0) : selection.createRange();
|
||||
try {
|
||||
var child = range.commonAncestorContainer.parentNode;
|
||||
for (var i = 0; i < 10; i++) {
|
||||
if (child.nodeName == "OL") {
|
||||
child.style["list-style"] = "lower-alpha";
|
||||
break;
|
||||
}
|
||||
if (child.parentNode) {
|
||||
child = child.parentNode
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RICH_EDITOR.setBullets = function () {
|
||||
document.execCommand('insertUnorderedList', false, null);
|
||||
var selection, type;
|
||||
if (window.getSelection) {
|
||||
selection = getSelection();
|
||||
}
|
||||
if (selection) {
|
||||
var range = selection.getRangeAt ? selection.getRangeAt(0) : selection.createRange();
|
||||
try {
|
||||
var child = range.commonAncestorContainer.parentNode;
|
||||
for (var i = 0; i < 10; i++) {
|
||||
if (child.nodeName == "UL") {
|
||||
child.style["list-style"] = "disc";
|
||||
break;
|
||||
}
|
||||
if (child.parentNode) {
|
||||
child = child.parentNode
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RICH_EDITOR.setSquare = function () {
|
||||
document.execCommand('insertUnorderedList', false, null);
|
||||
var selection, type;
|
||||
if (window.getSelection) {
|
||||
selection = getSelection();
|
||||
}
|
||||
if (selection) {
|
||||
var range = selection.getRangeAt ? selection.getRangeAt(0) : selection.createRange();
|
||||
try {
|
||||
var child = range.commonAncestorContainer.parentNode;
|
||||
for (var i = 0; i < 10; i++) {
|
||||
if (child.nodeName == "UL") {
|
||||
child.style["list-style"] = "square";
|
||||
break;
|
||||
}
|
||||
if (child.parentNode) {
|
||||
child = child.parentNode
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RICH_EDITOR.setTextColor = function (color) {
|
||||
document.execCommand('foreColor', false, color);
|
||||
}
|
||||
|
||||
RICH_EDITOR.setTextBackgroundColor = function(color) {
|
||||
RICH_EDITOR.restorerange();
|
||||
document.execCommand("styleWithCSS", null, true);
|
||||
document.execCommand('hiliteColor', false, color);
|
||||
document.execCommand("styleWithCSS", null, false);
|
||||
}
|
||||
|
||||
RICH_EDITOR.setFontSize = function(fontSize){
|
||||
document.execCommand("fontSize", false, fontSize);
|
||||
}
|
||||
|
||||
RICH_EDITOR.execFontSize = function (size, unit) {
|
||||
document.execCommand("fontSize", false, "7");
|
||||
var fontElements = window.getSelection().anchorNode.parentNode
|
||||
fontElements.removeAttribute("size");
|
||||
fontElements.style.fontSize = size + 'px'
|
||||
};
|
||||
|
||||
RICH_EDITOR.setHeading = function(heading) {
|
||||
document.execCommand('formatBlock', false, '<h'+heading+'>');
|
||||
}
|
||||
|
||||
RICH_EDITOR.setIndent = function() {
|
||||
document.execCommand('indent', false, null);
|
||||
}
|
||||
|
||||
RICH_EDITOR.setOutdent = function() {
|
||||
document.execCommand('outdent', false, null);
|
||||
}
|
||||
|
||||
RICH_EDITOR.setJustifyLeft = function() {
|
||||
document.execCommand('justifyLeft', false, null);
|
||||
}
|
||||
|
||||
RICH_EDITOR.setJustifyCenter = function() {
|
||||
document.execCommand('justifyCenter', false, null);
|
||||
}
|
||||
|
||||
RICH_EDITOR.setJustifyRight = function() {
|
||||
document.execCommand('justifyRight', false, null);
|
||||
}
|
||||
|
||||
RICH_EDITOR.setBlockquote = function() {
|
||||
document.execCommand('formatBlock', false, '<blockquote>');
|
||||
}
|
||||
|
||||
RICH_EDITOR.insertImage = function() {
|
||||
var url = './shuxue.png';
|
||||
var html = '<br></br><img src="' + url + '" alt="picvision" style="margin:0px auto;width:90%;display:table-cell;vertical-align:middle;border-radius:10px;max-width:90%" /><br></br>';
|
||||
RICH_EDITOR.insertHTML(html);
|
||||
RICH_EDITOR.editor.scrollIntoView(false)
|
||||
}
|
||||
|
||||
RICH_EDITOR.insertHTML = function(html) {
|
||||
RICH_EDITOR.restorerange();
|
||||
document.execCommand('insertHTML', false, html);
|
||||
}
|
||||
|
||||
RICH_EDITOR.setDone = function() {
|
||||
var html = '<input type="checkbox" checked="checked"/> ';
|
||||
document.execCommand('insertHTML', false, html);
|
||||
}
|
||||
|
||||
RICH_EDITOR.addTodo=function(e){
|
||||
KEY_ENTER=13;
|
||||
if(e.which == KEY_ENTER){
|
||||
var node=RICH_EDITOR.getSelectedAnchorNode();
|
||||
if(node&&node.nodeName=="#text"){
|
||||
node=node.parentElement;
|
||||
}
|
||||
if(node&&node.nodeName=="SPAN"&&node.previousElementSibling&&node.previousElementSibling.className=='note-checkbox'){
|
||||
RICH_EDITOR.setTodo();
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RICH_EDITOR.setTodo = function () {
|
||||
var parent = document.getElementById('editorjs')
|
||||
var isContentEmpty = parent.innerHTML.trim().length == 0 || parent.innerHTML == '<br>';
|
||||
var html = (isContentEmpty ? '' : '<br/>') + '<input name="checkbox" type="checkbox" onclick="onCheckChange(this)" class="note-checkbox"><span class="note-checkbox-txt"> </span>';
|
||||
document.execCommand('insertHTML', false, html);
|
||||
}
|
||||
|
||||
function onCheckChange(checkbox) {
|
||||
if (checkbox.checked == true) {
|
||||
checkbox.setAttribute("checked", "checked");
|
||||
} else {
|
||||
checkbox.removeAttribute("checked");
|
||||
}
|
||||
}
|
||||
|
||||
RICH_EDITOR.restorerange = function(){
|
||||
var selection = window.getSelection();
|
||||
selection.removeAllRanges();
|
||||
var range = document.createRange();
|
||||
range.setStart(RICH_EDITOR.currentSelection.startContainer, RICH_EDITOR.currentSelection.startOffset);
|
||||
range.setEnd(RICH_EDITOR.currentSelection.endContainer, RICH_EDITOR.currentSelection.endOffset);
|
||||
selection.addRange(range);
|
||||
}
|
||||
|
||||
//获取光标开始位置归属节点
|
||||
RICH_EDITOR.getSelectedAnchorNode=function(){
|
||||
var node,selection;
|
||||
if (window.getSelection) {
|
||||
selection = getSelection();
|
||||
node = selection.anchorNode;
|
||||
}
|
||||
if (!node && document.selection) {
|
||||
selection = document.selection
|
||||
var range = selection.getRangeAt ? selection.getRangeAt(0) : selection.createRange();
|
||||
node = range.commonAncestorContainer ? range.commonAncestorContainer :
|
||||
range.parentElement ? range.parentElement() : range.item(0);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
function get_html_content() {
|
||||
console.log('hhh Ark WebComponent');
|
||||
var htmlString = encodeURI(RICH_EDITOR.getHtml())
|
||||
var str = callBackToApp.callbackhtml(htmlString)
|
||||
console.log('hhh objName.test result:' + str);
|
||||
}
|
||||
|
||||
function save_html_content() {
|
||||
console.log('hhh Ark WebComponent');
|
||||
var htmlString = encodeURI(RICH_EDITOR.getHtml())
|
||||
var str = callBackToApp.callbackhtmlSave(htmlString)
|
||||
console.log('hhh objName.test result:' + str);
|
||||
}
|
@ -1,344 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
var mNeedToUpdateToolbarState = false;
|
||||
|
||||
function command(name) {
|
||||
document.execCommand(name);
|
||||
}
|
||||
|
||||
function setFontSize(value) {
|
||||
console.log("setFontSize() value : " + value);
|
||||
document.execCommand("fontSize", false, value);
|
||||
}
|
||||
|
||||
/** Font size change feature */
|
||||
function getFontSize() {
|
||||
var fontSize = document.queryCommandValue('fontSize');
|
||||
console.log("get current fontSize : " + fontSize);
|
||||
fontSize = getSupportedFontSize(fontSize);
|
||||
return fontSize;
|
||||
}
|
||||
|
||||
function getSupportedFontSize(fontSize) {
|
||||
var result = 16;
|
||||
switch (parseInt(fontSize)) {
|
||||
case 1:
|
||||
result = 12;
|
||||
break;
|
||||
case 2:
|
||||
result = 14;
|
||||
break;
|
||||
case 3:
|
||||
result = 16;
|
||||
break;
|
||||
case 4:
|
||||
result = 18;
|
||||
break;
|
||||
case 5:
|
||||
result = 20;
|
||||
break;
|
||||
case 6:
|
||||
result = 22;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
console.log("get supported fontSize : " + result);
|
||||
return result;
|
||||
}
|
||||
|
||||
function setForeColor(value) {
|
||||
console.log("setForeColor() value : " + value);
|
||||
document.execCommand("foreColor", false, value);
|
||||
}
|
||||
|
||||
function getFontColor() {
|
||||
var fontColor = document.queryCommandValue('foreColor');
|
||||
console.log("get current fontColor : " + fontColor);
|
||||
return fontColor;
|
||||
}
|
||||
|
||||
function updateRichTextState() {
|
||||
var result = 0x0;
|
||||
var boldState = getCurrentBoldState();
|
||||
result |= boldState;
|
||||
|
||||
var italicState = getCurrentItalicState();
|
||||
result |= italicState;
|
||||
|
||||
var underlineState = getCurrentUnderlineState();
|
||||
result |= underlineState;
|
||||
|
||||
var orderedListState = getCurrentOrderedListState();
|
||||
result |= orderedListState;
|
||||
|
||||
var unorderedListState = getCurrentUnorderedListState();
|
||||
result |= unorderedListState;
|
||||
|
||||
var alignLeftState = getCurrentAlignLeftState();
|
||||
result |= alignLeftState;
|
||||
|
||||
var alignCenterState = getCurrentAlignCenterState();
|
||||
result |= alignCenterState;
|
||||
|
||||
var alignRightState = getCurrentAlignRightState();
|
||||
result |= alignRightState;
|
||||
|
||||
// font size
|
||||
var fontSize = getFontSize();
|
||||
|
||||
// font color
|
||||
var foreColor = getFontColor();
|
||||
|
||||
var undoState = getCurrentUndoState();
|
||||
result |= undoState;
|
||||
|
||||
var redoState = getCurrentRedoState();
|
||||
result |= redoState;
|
||||
|
||||
if (window.updateRichEditStateFinished && window.updateRichEditStateFinished.call) {
|
||||
updateRichEditStateFinished.call(result + "&" + fontSize + "&" + foreColor);
|
||||
}
|
||||
}
|
||||
|
||||
function getCurrentUndoState() {
|
||||
var undoState = 0x0;
|
||||
var canUndo = document.queryCommandEnabled("undo");
|
||||
if (canUndo == true) {
|
||||
undoState |= 0x400;
|
||||
}
|
||||
return undoState;
|
||||
}
|
||||
|
||||
function getCurrentRedoState() {
|
||||
var redoState = 0x0;
|
||||
var canRedo = document.queryCommandEnabled("redo");
|
||||
if (canRedo == true) {
|
||||
redoState |= 0x800;
|
||||
}
|
||||
return redoState;
|
||||
}
|
||||
|
||||
function getCurrentAlignLeftState() {
|
||||
var alignLeftState = 0x0;
|
||||
var state = document.queryCommandState("justifyLeft");
|
||||
var indeterm = document.queryCommandIndeterm("justifyLeft");
|
||||
if (state == true) {
|
||||
alignLeftState |= 0x1000;
|
||||
} else if (state == false) {
|
||||
if (indeterm == true) {
|
||||
alignLeftState |= 0x2000;
|
||||
} else {
|
||||
alignLeftState |= 0x0;
|
||||
}
|
||||
} else if (state == null) {
|
||||
alignLeftState |= 0x0;
|
||||
}
|
||||
return alignLeftState;
|
||||
}
|
||||
|
||||
function getCurrentAlignCenterState() {
|
||||
var alignCenterState = 0x0;
|
||||
var state = document.queryCommandState("justifyCenter");
|
||||
var indeterm = document.queryCommandIndeterm("justifyCenter");
|
||||
if (state == true) {
|
||||
alignCenterState |= 0x4000;
|
||||
} else if (state == false) {
|
||||
if (indeterm == true) {
|
||||
alignCenterState |= 0x8000;
|
||||
} else {
|
||||
alignCenterState |= 0x0;
|
||||
}
|
||||
} else if (state == null) {
|
||||
alignCenterState |= 0x0;
|
||||
}
|
||||
return alignCenterState;
|
||||
}
|
||||
|
||||
function getCurrentAlignRightState() {
|
||||
var alignRightState = 0x0;
|
||||
var state = document.queryCommandState("justifyRight");
|
||||
var indeterm = document.queryCommandIndeterm("justifyRight");
|
||||
if (state == true) {
|
||||
alignRightState |= 0x10000;
|
||||
} else if (state == false) {
|
||||
if (indeterm == true) {
|
||||
alignRightState |= 0x20000;
|
||||
} else {
|
||||
alignRightState |= 0x0;
|
||||
}
|
||||
} else if (state == null) {
|
||||
alignRightState |= 0x0;
|
||||
}
|
||||
return alignRightState;
|
||||
}
|
||||
|
||||
function getCurrentOrderedListState() {
|
||||
var orderedListState = 0x0;
|
||||
var state = document.queryCommandState("insertOrderedList");
|
||||
var indeterm = document.queryCommandIndeterm("insertOrderedList");
|
||||
|
||||
var selection, type;
|
||||
if (window.getSelection) {
|
||||
selection = getSelection();
|
||||
}
|
||||
if (selection) {
|
||||
var range = selection.getRangeAt ? selection.getRangeAt(0) : selection.createRange();
|
||||
try {
|
||||
var child = range.commonAncestorContainer.parentNode;
|
||||
for (var i = 0; i < 10; i++) {
|
||||
if (child.nodeName == "OL") {
|
||||
type = child.style["list-style"];
|
||||
break;
|
||||
}
|
||||
if (child.parentNode) {
|
||||
child = child.parentNode
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
|
||||
}
|
||||
}
|
||||
if (state == true) {
|
||||
if (type == "lower-alpha") {
|
||||
orderedListState |= 0x40000;
|
||||
} else {
|
||||
orderedListState |= 0x40;
|
||||
}
|
||||
} else if (state == false) {
|
||||
if (indeterm == true) {
|
||||
orderedListState |= 0x80;
|
||||
} else {
|
||||
orderedListState |= 0x0;
|
||||
}
|
||||
} else if (state == null) {
|
||||
orderedListState |= 0x0;
|
||||
}
|
||||
return orderedListState;
|
||||
}
|
||||
|
||||
function getCurrentUnorderedListState() {
|
||||
var unorderedListState = 0x0;
|
||||
var state = document.queryCommandState("insertUnorderedList");
|
||||
var indeterm = document.queryCommandIndeterm("insertUnorderedList");
|
||||
|
||||
var selection, type;
|
||||
if (window.getSelection) {
|
||||
selection = getSelection();
|
||||
}
|
||||
if (selection) {
|
||||
var range = selection.getRangeAt ? selection.getRangeAt(0) : selection.createRange();
|
||||
try {
|
||||
var child = range.commonAncestorContainer.parentNode;
|
||||
for (var i = 0; i < 10; i++) {
|
||||
if (child.nodeName == "UL") {
|
||||
type = child.style["list-style"];
|
||||
break;
|
||||
}
|
||||
if (child.parentNode) {
|
||||
child = child.parentNode
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
|
||||
}
|
||||
}
|
||||
if (state == true) {
|
||||
if (type == "square") {
|
||||
unorderedListState |= 0x100000;
|
||||
} else {
|
||||
unorderedListState |= 0x100;
|
||||
}
|
||||
} else if (state == false) {
|
||||
if (indeterm == true) {
|
||||
unorderedListState |= 0x200;
|
||||
} else {
|
||||
unorderedListState |= 0x0;
|
||||
}
|
||||
} else if (state == null) {
|
||||
unorderedListState |= 0x0;
|
||||
}
|
||||
return unorderedListState;
|
||||
}
|
||||
|
||||
function getCurrentUnderlineState() {
|
||||
var underlineState = 0x0;
|
||||
var state = document.queryCommandState("underline");
|
||||
var indeterm = document.queryCommandIndeterm("underline");
|
||||
if (state == true) {
|
||||
underlineState |= 0x10;
|
||||
} else if (state == false) {
|
||||
if (indeterm == true) {
|
||||
underlineState |= 0x20;
|
||||
} else {
|
||||
underlineState |= 0x0;
|
||||
}
|
||||
} else if (state == null) {
|
||||
underlineState |= 0x0;
|
||||
}
|
||||
return underlineState;
|
||||
}
|
||||
|
||||
function getCurrentItalicState() {
|
||||
var italicState = 0x0;
|
||||
var state = document.queryCommandState("italic");
|
||||
var indeterm = document.queryCommandIndeterm("italic");
|
||||
if (state == true) {
|
||||
italicState |= 0x4;
|
||||
} else if (state == false) {
|
||||
if (indeterm == true) {
|
||||
italicState |= 0x8;
|
||||
} else {
|
||||
italicState |= 0x0;
|
||||
}
|
||||
} else if (state == null) {
|
||||
italicState |= 0x0;
|
||||
}
|
||||
return italicState;
|
||||
}
|
||||
|
||||
function getCurrentBoldState() {
|
||||
var boldState = 0x0;
|
||||
var state = document.queryCommandState("bold");
|
||||
var indeterm = document.queryCommandIndeterm("bold");
|
||||
if (state == true) {
|
||||
boldState |= 0x1;
|
||||
} else if (state == false) {
|
||||
if (indeterm == true) {
|
||||
boldState |= 0x2;
|
||||
} else {
|
||||
boldState |= 0x0;
|
||||
}
|
||||
} else if (state == null) {
|
||||
boldState |= 0x0;
|
||||
}
|
||||
return boldState;
|
||||
}
|
||||
|
||||
function onSelectionChanged(event) {
|
||||
switch (event.type) {
|
||||
case "selectstart":
|
||||
mNeedToUpdateToolbarState = true;
|
||||
break;
|
||||
case "selectionchange":
|
||||
{
|
||||
if (mNeedToUpdateToolbarState) {
|
||||
updateRichTextState();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|