!21 note update

Merge pull request !21 from jiangchengfeixue/master
This commit is contained in:
openharmony_ci
2022-04-12 10:24:41 +00:00
committed by Gitee
33 changed files with 698 additions and 426 deletions
+2 -2
View File
@@ -3,8 +3,8 @@
"bundleName": "com.ohos.note",
"vendor": "ohos",
"version": {
"code": 1000000,
"name": "1.0.0"
"code": 1000003,
"name": "1.0.3"
}
},
"deviceConfig": {},
@@ -60,7 +60,7 @@ export struct NewOrEditFolderDialog {
.maxLength(20)
.borderRadius(15)
.backgroundColor($r("app.color.New_folder_input_box_color"))
.width('90%')
.width('100%')
.onChange((value: string) => {
this.inputName = value
FolderUtil.duplicateDetection(this.inputName, this.AllFolderArray).then(result => {
@@ -69,15 +69,17 @@ export struct NewOrEditFolderDialog {
})
}.margin({ bottom: 4, left: 24, right: 24 })
Divider()
.height(1)
.margin({ left: 64, right: 24 })
.color((this.isExisted && this.inputName != this.oriInputName) ? $r("app.color.category_already_exist_divider_color"):$r("app.color.divider_color_182431"))
Text($r("app.string.category_already_exist"))
.fontSize(10)
.margin({ left: 64 })
.margin({ left: 64, top: 4 })
.fontColor($r("app.color.category_already_exist_font_color"))
.visibility((this.isExisted && this.inputName != this.oriInputName) ? Visibility.Visible : Visibility.None)
Divider()
.height(1)
.margin({ left: 64, right: 24 })
.color($r("app.color.divider_color_182431"))
// button group
Flex({ wrap: FlexWrap.Wrap, justifyContent: FlexAlign.SpaceBetween }) {
Text($r("app.string.cancel"))
@@ -305,6 +307,7 @@ export struct NoteDataMoveDialog {
Flex({ alignItems: ItemAlign.Center }) {
Text($r("app.string.chooseFolder"))
.fontSize(20)
.fontWeight(600)
}.height(56)
.width(288)
@@ -325,7 +328,7 @@ export struct NoteDataMoveDialog {
Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text($r("app.string.cancel"))
.fontSize(16)
.fontColor($r("app.color.text_color_3f97e9"))
.fontColor($r("app.color.button_color_f86d05"))
.onClick(() => {
this.noteDataMoveDialogCtl.close()
})
@@ -42,7 +42,6 @@ export struct FolderListComp {
.onClick(() => {
if (this.sectionStatus == 1) {
this.expandStatus = !this.expandStatus
AppStorage.SetOrCreate('ContinueExpand', this.expandStatus)
} else {
this.sectionStatus = (this.sectionStatus == 3 ? 2 : 3)
// save continue data
@@ -56,7 +55,7 @@ export struct FolderListComp {
.padding({ left: 24 })
NoteAndCreateComp()
// center
// center
List() {
ForEach(this.AllFolderArray, (folderItem: FolderData) => {
ListItem() {
@@ -67,6 +66,7 @@ export struct FolderListComp {
}, folderItem => folderItem.name.toString())
}.width('100%')
.padding({ left: 12, right: 12 })
Blank()
Column() {
FolderItemComp({
@@ -92,7 +92,6 @@ export struct FolderListComp {
aboutToDisappear(): void{
LogUtil.info(this.TAG, "aboutToDisappear")
}
}
@Component
@@ -362,7 +361,11 @@ struct FolderItemComp {
this.selectedFolderData = this.folderItem
this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), this.folderItem.uuid)
// 刷新web界面
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')" })
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())
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
@@ -37,9 +37,10 @@ var timeID: number
@Component
export struct NoteContent {
@Provide('SelectedNoteData') selectedNoteData: NoteData = AppStorage.Get("NewNote")
@Provide('SelectedNoteData') selectedNoteData: NoteData = AppStorage.Get('NewNote')
@StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray')
@Provide('Issave') issave: number = 0
@Provide('EditModel') editModel: boolean = false
controllerShow: WebController
private editContentFlag = false
@@ -49,12 +50,13 @@ export struct NoteContent {
this.selectedNoteData.content_text = html
this.selectedNoteData.modified_time = new Date().getTime()
// updata note image
this.selectedNoteData.content_img = RdbStoreUtil.updataNoteImage(this.selectedNoteData.content_text)
this.selectedNoteData.content_img = RdbStoreUtil.updataNoteImage(this.selectedNoteData)
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.uuid)
AppStorage.SetOrCreate<NoteData>('NewNote', this.selectedNoteData)
AppStorage.SetOrCreate<boolean>('needRefresh',true)
// save continue data
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
@@ -66,7 +68,7 @@ export struct NoteContent {
this.selectedNoteData.content_text = html
this.selectedNoteData.modified_time = new Date().getTime()
// updata note image
this.selectedNoteData.content_img = RdbStoreUtil.updataNoteImage(this.selectedNoteData.content_text)
this.selectedNoteData.content_img = RdbStoreUtil.updataNoteImage(this.selectedNoteData)
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid)
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null)
@@ -80,11 +82,11 @@ export struct NoteContent {
build() {
Stack({ alignContent: Alignment.Bottom }) {
Flex({ direction: FlexDirection.Column, wrap: FlexWrap.Wrap,
Flex({ direction: FlexDirection.Column, wrap: FlexWrap.NoWrap,
alignItems: ItemAlign.Start, alignContent: FlexAlign.SpaceAround }) {
Column() {
ToolBarComp({ controllerShow: this.controllerShow })
}
}.margin({ left: 24, right: 24 })
Column() {
NoteContentOverViewComp()
@@ -106,22 +108,22 @@ export struct NoteContent {
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')" })
})
.zoomAccess(false)
.height(450)
.height('70%')
.width('100%')
}
.margin({ top: 16 })
.margin({ left: 12, right: 24, top: 16 })
.width(StyleConstants.PERCENTAGE_100)
.onClick(() => {
this.issave = 0
// 添加定时器:3s自动保存
timeID = setInterval(() => {
this.controllerShow.runJavaScript({ script: "scheduled_save_content()" })
}, 3000)
LogUtil.info(TAG, "setInterval timeID : " + timeID)
this.issave = 0
this.editModel = true
})
}
.height(StyleConstants.PERCENTAGE_100)
.margin({ left: 24, right: 24 })
}
.height(StyleConstants.PERCENTAGE_100)
.width(StyleConstants.PERCENTAGE_100)
@@ -141,6 +143,7 @@ export struct ToolBarComp {
@Consume('SelectedNoteData') selectedNoteData: NoteData
@StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray')
@Consume('Issave') issave: number
@Consume('EditModel') editModel: boolean
controllerShow: WebController
editContentDialogCtl: CustomDialogController = new CustomDialogController({
@@ -157,7 +160,7 @@ export struct ToolBarComp {
build() {
Flex({ direction: FlexDirection.Row, wrap: FlexWrap.NoWrap,
justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
Image($r('app.media.zoom'))
Image($r('app.media.narrow'))
.height(24)
.width(24)
.onClick(() => {
@@ -168,131 +171,141 @@ export struct ToolBarComp {
LogUtil.info(TAG, "zoom, clearInterval timeID : " + timeID)
clearInterval(timeID)
}
// 退出键盘
inputMethod.getInputMethodController().stopInput();
router.back()
})
.visibility(this.selectedNoteData.is_deleted == Delete.Yes ? Visibility.None : Visibility.Visible)
Row({ space: StyleConstants.SPACE_6 }) {
Button({ type: ButtonType.Normal, stateEffect: true }) {
Image($r('app.media.circle_tick1'))
.height(24)
.width(24)
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(() => {
// 退出键盘
inputMethod.getInputMethodController().stopInput();
// 清单
this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.setTodo()" })
this.selectedNoteData.is_favorite = (this.selectedNoteData.is_favorite == Favorite.Yes ? Favorite.No : Favorite.Yes)
// 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)
// save continue data
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
LogUtil.info(TAG, 'ToolBarComp, set continue note success')
})
}.width(42)
.height(42)
.borderRadius(8)
.backgroundColor($r('app.color.color_ffffff'))
Button({ type: ButtonType.Normal, stateEffect: true }) {
Image($r('app.media.font_style'))
.height(24)
.width(24)
.onClick(() => {
// 退出键盘
inputMethod.getInputMethodController().stopInput();
LogUtil.info(TAG, 'editContentDialogCtl start')
this.editContentDialogCtl.open()
})
}.width(42)
.height(42)
.borderRadius(8)
.backgroundColor($r('app.color.color_ffffff'))
Button({ type: ButtonType.Normal, stateEffect: true }) {
Image($r('app.media.picture_white')).height(24).width(24)
.onClick(async () => {
// 退出键盘
inputMethod.getInputMethodController().stopInput();
LogUtil.info(TAG, 'startAbility start')
AppStorage.SetOrCreate<number>('openPhoto', 1)
await globalThis.noteContext.startAbilityForResult({
parameters: { uri: "singleselect" },
bundleName: "com.ohos.photos",
abilityName: "com.ohos.photos.MainAbility",
}.width(36)
.visibility(this.selectedNoteData.is_deleted == Delete.Yes ? Visibility.None : Visibility.Visible)
} else {
Row({ space: StyleConstants.SPACE_6 }) {
Button({ type: ButtonType.Normal, stateEffect: true }) {
Image($r('app.media.circle_tick1'))
.height(24)
.width(24)
.onClick(() => {
// 退出键盘
inputMethod.getInputMethodController().stopInput();
// 清单
this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.setTodo()" })
})
.then(v => {
AppStorage.SetOrCreate<number>('openPhoto', 0)
let want = v['want'];
if (want != null && want != undefined) {
let param = want['parameters'];
let imageUri = ""
if (param != null && param != undefined) {
let uri = param['select-item-list'];
imageUri = uri;
}.width(42)
.height(42)
.borderRadius(8)
.backgroundColor($r('app.color.color_ffffff'))
Button({ type: ButtonType.Normal, stateEffect: true }) {
Image($r('app.media.font_style'))
.height(24)
.width(24)
.onClick(() => {
// 退出键盘
inputMethod.getInputMethodController().stopInput();
LogUtil.info(TAG, 'editContentDialogCtl start')
this.editContentDialogCtl.open()
})
}.width(42)
.height(42)
.borderRadius(8)
.backgroundColor($r('app.color.color_ffffff'))
Button({ type: ButtonType.Normal, stateEffect: true }) {
Image($r('app.media.picture_white')).height(24).width(24)
.onClick(async () => {
// 退出键盘
inputMethod.getInputMethodController().stopInput();
LogUtil.info(TAG, 'startAbility start')
await globalThis.noteContext.startAbilityForResult({
parameters: { uri: "singleselect" },
bundleName: "com.ohos.photos",
abilityName: "com.ohos.photos.MainAbility",
})
.then(v => {
let want = v['want'];
if (want != null && want != undefined) {
let param = want['parameters'];
let imageUri = ""
if (param != null && param != undefined) {
let uri = param['select-item-list'];
imageUri = uri;
}
// 拷贝
if(imageUri != null && imageUri != "") {
OperationUtils.copy(imageUri).then((uriPath) => {
var path = "file://" + uriPath
LogUtil.info(TAG, 'image uri is:' + path)
this.controllerShow.runJavaScript({script:"javascript:RICH_EDITOR.insertImage('" + path + "')"})
})
}
}
// 拷贝
if(imageUri != null && imageUri != "") {
OperationUtils.copy(imageUri).then((uriPath) => {
var path = "file://" + uriPath
LogUtil.info(TAG, 'image uri is:' + path)
this.controllerShow.runJavaScript({script:"javascript:RICH_EDITOR.insertImage('" + path + "')"})
})
}
}
});
})
}.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.tick_thick'))
.height(24)
.width(24)
.fillColor(this.issave == 0 ? Color.Black : Color.Grey)
.onClick(() => {
this.issave = 1
// 清除定时器
if (timeID != undefined) {
LogUtil.info(TAG, "tick_thick, clearInterval timeID : " + timeID)
clearInterval(timeID)
}
// 退出键盘
inputMethod.getInputMethodController().stopInput();
// 保存笔记信息到数据库
this.controllerShow.runJavaScript({ script: "get_html_content()" })
})
}.width(42)
.height(42)
.borderRadius(8)
.backgroundColor($r('app.color.color_ffffff'))
Button({ type: ButtonType.Normal, stateEffect: true }) {
Image($r('app.media.undo'))
.height(24)
.width(24)
.onClick(() => {
// 退出键盘
inputMethod.getInputMethodController().stopInput();
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.undo()" })
})
}.width(42)
.height(42)
.borderRadius(8)
.backgroundColor($r('app.color.color_ffffff'))
Button({ type: ButtonType.Normal, stateEffect: true }) {
Image($r('app.media.undo'))
.height(24)
.width(24)
.onClick(() => {
// 退出键盘
inputMethod.getInputMethodController().stopInput();
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.undo()" })
})
}.width(42)
.height(42)
.borderRadius(8)
.backgroundColor($r('app.color.color_ffffff'))
Button({ type: ButtonType.Normal, stateEffect: true }) {
Image($r('app.media.todo'))
.height(24)
.width(24)
.onClick(() => {
// 退出键盘
inputMethod.getInputMethodController().stopInput();
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.redo()" })
})
}.width(42)
.height(42)
.borderRadius(8)
.backgroundColor($r('app.color.color_ffffff'))
}.width(274)
Button({ type: ButtonType.Normal, stateEffect: true }) {
Image($r('app.media.todo'))
.height(24)
.width(24)
.onClick(() => {
// 退出键盘
inputMethod.getInputMethodController().stopInput();
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.redo()" })
})
}.width(42)
.height(42)
.borderRadius(8)
.backgroundColor($r('app.color.color_ffffff'))
Button({ type: ButtonType.Normal, stateEffect: true }) {
Image($r('app.media.tick_thick'))
.height(24)
.width(24)
.fillColor(this.issave == 0 ? Color.Black : Color.Grey)
.onClick(() => {
this.issave = 1
// 保存笔记信息到数据库
this.controllerShow.runJavaScript({ script: "get_html_content()" })
})
}.width(42)
.height(42)
.borderRadius(8)
.backgroundColor($r('app.color.color_ffffff'))
}.width(274)
}
}
.width(StyleConstants.PERCENTAGE_100)
.height(80)
@@ -354,7 +367,9 @@ export struct NoteContentOverViewComp {
Flex({ direction: FlexDirection.Column, wrap: FlexWrap.NoWrap,
justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
Row() {
Text(this.selectedNoteData.title).fontSize(30)
Text(this.selectedNoteData.title)
.fontSize(30)
.margin({ left: 12, right: 24 })
.onClick(() => {
this.editTitleDialogCtl.open()
})
@@ -366,9 +381,11 @@ export struct NoteContentOverViewComp {
.fontSize(12)
.padding({ top: 4, bottom: 4 })
.fontColor($r("app.color.modified_time_font_color"))
.margin({ left: 12 })
Row() {
Text(FolderUtil.getFolderText(FolderUtil.getFolderData(AppStorage.Get('AllFolderArray'), this.selectedNoteData.folder_uuid)))
.fontSize(12)
.fontColor($r("app.color.list_modified_time_font_color"))
Image($r('app.media.triangle'))
.width(6)
.height(12)
@@ -54,7 +54,7 @@ export struct NoteContentComp {
this.selectedNoteData.content_text = html
this.selectedNoteData.modified_time = new Date().getTime()
// updata note image
this.selectedNoteData.content_img = RdbStoreUtil.updataNoteImage(this.selectedNoteData.content_text)
this.selectedNoteData.content_img = RdbStoreUtil.updataNoteImage(this.selectedNoteData)
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid)
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null)
@@ -71,7 +71,7 @@ export struct NoteContentComp {
this.selectedNoteData.content_text = html
this.selectedNoteData.modified_time = new Date().getTime()
// updata note image
this.selectedNoteData.content_img = RdbStoreUtil.updataNoteImage(this.selectedNoteData.content_text)
this.selectedNoteData.content_img = RdbStoreUtil.updataNoteImage(this.selectedNoteData)
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid)
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null)
@@ -91,7 +91,7 @@ export struct NoteContentComp {
this.selectedNoteData.content_text = html
this.selectedNoteData.modified_time = new Date().getTime()
// updata note image
this.selectedNoteData.content_img = RdbStoreUtil.updataNoteImage(this.selectedNoteData.content_text)
this.selectedNoteData.content_img = RdbStoreUtil.updataNoteImage(this.selectedNoteData)
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid)
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null)
@@ -111,9 +111,10 @@ export struct NoteContentComp {
Column() {
ToolBarComp({ controllerShow: this.controllerShow })
}
.margin({ left: 24, right: 24 })
Column() {
NoteContentOverViewComp()
NoteContentOverViewComp({ controllerShow: this.controllerShow })
Text(this.refreshFlag.toString()).visibility(Visibility.None)
Text(this.AllNoteArray.length.toString()).visibility(Visibility.None) // 用于强制刷新使用
@@ -138,20 +139,22 @@ export struct NoteContentComp {
}
})
.zoomAccess(false)
.height(450)
.height('70%')
.width('100%')
}
.margin({ top: 16 })
.margin({ left: 12, right: 24, top: 16 })
.width(StyleConstants.PERCENTAGE_100)
.enabled(this.selectedNoteData.is_deleted == Delete.Yes ? false : true)
.onClick(() => {
this.issave = 0
LogUtil.info(TAG, "editModel : " + this.editModel + ", sectionStatus : " + this.sectionStatus)
let isContinue = AppStorage.Get<boolean>('IsContinue')
LogUtil.info(TAG, "isContinue : " + isContinue)
// 点击第三屏进入全屏编辑模式
if (this.sectionStatus != 1) {
if (this.sectionStatus != 1 || isContinue) {
this.lastSectionStatus = this.sectionStatus
this.sectionStatus = 1
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setInputEnabled(true)" })
this.editModel = !this.editModel
// 添加定时器:3s自动保存
timeId = setInterval(() => {
this.controllerShow.runJavaScript({ script: "scheduled_save_content()" })
@@ -160,11 +163,12 @@ export struct NoteContentComp {
// save continue data
AppStorage.SetOrCreate<number>('ContinueSection', this.sectionStatus)
LogUtil.info(TAG, "set continue section success")
this.editModel = !this.editModel
AppStorage.SetOrCreate<boolean>('IsContinue', false)
}
})
}
.height(StyleConstants.PERCENTAGE_100)
.margin({ left: 24, right: 24 })
.visibility(FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid) == 0 ? Visibility.Hidden : Visibility.Visible)
}
.height(StyleConstants.PERCENTAGE_100)
@@ -186,9 +190,12 @@ export struct NoteContentOverViewComp {
@Consume('SelectedNoteData') selectedNoteData: NoteData
@StorageLink('AllFolderArray') AllFolderArray: FolderData[] = []
@StorageLink('CheckedNoteArray') CheckedNoteArray: NoteData[] = []
@StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray')
@Consume('SelectedFolderData') selectedFolderData: FolderData
@Consume('EditModel') editModel: boolean
@Consume('SectionStatus') sectionStatus: number
@Consume('RefreshFlag') refreshFlag: number
controllerShow: WebController
editTitleDialogCtl: CustomDialogController = new CustomDialogController({
builder: EditTitleDialog({ confirm: this.confirm.bind(this), dialogType: 0 }),
alignment: DialogAlignment.Center,
@@ -216,7 +223,17 @@ export struct NoteContentOverViewComp {
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid)
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null)
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
if(this.sectionStatus != 1) {
this.selectedNoteData = NoteUtil.getFirstNoteData(this.AllNoteArray, this.selectedFolderData.uuid)
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')" })
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
} else {
this.selectedFolderData = FolderUtil.getFolderData(AppStorage.Get('AllFolderArray'), item.uuid)
}
// save continue data
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
LogUtil.info(TAG, "NoteContentOverViewComp, MenuBuilder, set continue note success")
})
}, noteItem => noteItem.uuid)
}.listDirection(Axis.Vertical)
@@ -232,7 +249,9 @@ export struct NoteContentOverViewComp {
Flex({ direction: FlexDirection.Column, wrap: FlexWrap.NoWrap,
justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
Row() {
Text(this.selectedNoteData.title).fontSize(30)
Text(this.selectedNoteData.title)
.fontSize(30)
.margin({ left: 12, right: 24 })
.onClick(() => {
this.editModel = true
this.sectionStatus = 1
@@ -249,9 +268,11 @@ export struct NoteContentOverViewComp {
.fontSize(12)
.padding({ top: 4, bottom: 4 })
.fontColor($r("app.color.modified_time_font_color"))
.margin({ left: 12 })
Row() {
Text(FolderUtil.getFolderText(FolderUtil.getFolderData(AppStorage.Get('AllFolderArray'), this.selectedNoteData.folder_uuid)))
.fontSize(12)
.fontColor($r("app.color.list_modified_time_font_color"))
Image($r('app.media.triangle'))
.width(6)
.height(12)
@@ -311,11 +332,10 @@ export struct ToolBarComp {
this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid)
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')" })
this.chooseNote = false
AppStorage.SetOrCreate('ContinueChoose', this.chooseNote)
// save continue data
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
LogUtil.info(TAG, "NoteContentOverViewComp, set continue section success")
LogUtil.info(TAG, "NoteContentOverViewComp, set continue note success")
}
editContentDialogCtl: CustomDialogController = new CustomDialogController({
@@ -332,7 +352,7 @@ export struct ToolBarComp {
build() {
Flex({ direction: FlexDirection.Row, wrap: FlexWrap.NoWrap,
justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
Image($r('app.media.zoom'))
Image(this.sectionStatus == 1 ? $r('app.media.narrow') : $r('app.media.zoom'))
.height(24)
.width(24)
.onClick(() => {
@@ -342,8 +362,6 @@ export struct ToolBarComp {
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setInputEnabled(true)" })
} else {
if (this.lastSectionStatus != undefined) {
// 退出键盘
inputMethod.getInputMethodController().stopInput();
// 切换为小屏预览模式
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setInputEnabled(false)" })
// 退出全屏时存库
@@ -382,7 +400,6 @@ export struct ToolBarComp {
prompt.showToast({ message: "已恢复", duration: 2000 })
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
this.chooseNote = false
AppStorage.SetOrCreate('ContinueChoose', this.chooseNote)
// update note to db
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid)
@@ -403,15 +420,10 @@ export struct ToolBarComp {
.height(24)
.width(24)
.onClick(() => {
// 退出键盘
inputMethod.getInputMethodController().stopInput();
// 清单
this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.setTodo()" })
// 清除定时器
if (timeId != undefined) {
LogUtil.info(TAG, "circle_tick1, clearInterval timeId : " + timeId)
clearInterval(timeId)
}
// 退出键盘
inputMethod.getInputMethodController().stopInput();
})
}.width(42)
.height(42)
@@ -436,31 +448,41 @@ export struct ToolBarComp {
Image($r('app.media.picture_white'))
.height(24)
.width(24)
}.width(42)
.height(42)
.borderRadius(8)
.backgroundColor($r('app.color.color_ffffff'))
Button({ type: ButtonType.Normal, stateEffect: true }) {
Image($r('app.media.tick_thick'))
.height(24)
.width(24)
.fillColor(this.issave == 0 ? Color.Black : Color.Grey)
.onClick(() => {
.onClick(async () => {
// 退出键盘
inputMethod.getInputMethodController().stopInput();
this.issave = 1
// 保存笔记信息到数据库
this.controllerShow.runJavaScript({ script: "get_html_content()" })
if (this.selectedNoteData.title == "标题" && this.selectedNoteData.content_text == "") {
LogUtil.info(TAG, "note is empty,save note failed")
}
LogUtil.info(TAG, 'startAbility start')
await globalThis.noteContext.startAbilityForResult({
parameters: { uri: "singleselect" },
bundleName: "com.ohos.photos",
abilityName: "com.ohos.photos.MainAbility",
})
.then(v => {
let want = v['want'];
if (want != null && want != undefined) {
let param = want['parameters'];
let imageUri = ""
if (param != null && param != undefined) {
let uri = param['select-item-list'];
imageUri = uri;
}
// 拷贝
if(imageUri != null && imageUri != "") {
OperationUtils.copy(imageUri).then((uriPath) => {
var path = "file://" + uriPath
LogUtil.info(TAG, 'image uri is:' + path)
this.controllerShow.runJavaScript({script:"javascript:RICH_EDITOR.insertImage('" + path + "')"})
})
}
}
});
})
}.width(42)
.height(42)
.borderRadius(8)
.backgroundColor($r('app.color.color_ffffff'))
Button({ type: ButtonType.Normal, stateEffect: true }) {
Image($r('app.media.undo'))
.height(24)
@@ -488,6 +510,25 @@ export struct ToolBarComp {
.height(42)
.borderRadius(8)
.backgroundColor($r('app.color.color_ffffff'))
Button({ type: ButtonType.Normal, stateEffect: true }) {
Image($r('app.media.tick_thick'))
.height(24)
.width(24)
.fillColor(this.issave == 0 ? Color.Black : Color.Grey)
.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")
}
this.issave = 1
})
}.width(42)
.height(42)
.borderRadius(8)
.backgroundColor($r('app.color.color_ffffff'))
}.width(274)
} else {
Row({ space: StyleConstants.SPACE_24 }) {
@@ -37,7 +37,7 @@ const TAG = "NoteContentCompPortrait"
// Note content component
@Component
export struct NoteContentCompPortrait {
@Provide('SelectedNoteData') selectedNoteData: NoteData = AppStorage.Get("NewNote")
@Provide('SelectedNoteData') selectedNoteData: NoteData = AppStorage.Get('NewNote')
@Provide('SelectedFolderData') selectedFolderData: FolderData = AppStorage.Get("NewFolder")
@StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray')
@Provide('EditModel') editModel: boolean = false
@@ -49,7 +49,7 @@ export struct NoteContentCompPortrait {
this.selectedNoteData.content_text = html
this.selectedNoteData.modified_time = new Date().getTime()
// updata note image
this.selectedNoteData.content_img = RdbStoreUtil.updataNoteImage(this.selectedNoteData.content_text)
this.selectedNoteData.content_img = RdbStoreUtil.updataNoteImage(this.selectedNoteData)
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid)
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null)
@@ -65,7 +65,7 @@ export struct NoteContentCompPortrait {
this.selectedNoteData.content_text = html
this.selectedNoteData.modified_time = new Date().getTime()
// updata note image
this.selectedNoteData.content_img = RdbStoreUtil.updataNoteImage(this.selectedNoteData.content_text)
this.selectedNoteData.content_img = RdbStoreUtil.updataNoteImage(this.selectedNoteData)
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid)
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null)
@@ -79,7 +79,7 @@ export struct NoteContentCompPortrait {
build() {
Stack({ alignContent: Alignment.Bottom }) {
Flex({ direction: FlexDirection.Column, wrap: FlexWrap.Wrap,
Flex({ direction: FlexDirection.Column, wrap: FlexWrap.NoWrap,
alignItems: ItemAlign.Start, alignContent: FlexAlign.SpaceAround }) {
Column() {
ToolBarComp({ controllerShow: this.controllerShow })
@@ -107,16 +107,16 @@ export struct NoteContentCompPortrait {
})
})
.zoomAccess(false)
.height(450)
.height('70%')
.width('100%')
}
.onClick(() => {
this.editModel = true
// 添加定时器:3s自动保存
time_id = setInterval(() => {
this.controllerShow.runJavaScript({ script: "scheduled_save_content()" })
}, 3000)
LogUtil.info(TAG, "setInterval time_id : " + time_id)
this.editModel = true
})
.margin({ top: 16 })
.width(StyleConstants.PERCENTAGE_100)
@@ -251,8 +251,6 @@ export struct ToolBarComp {
LogUtil.info(TAG, "back, clearInterval time_id : " + time_id)
clearInterval(time_id)
}
// 退出键盘
inputMethod.getInputMethodController().stopInput();
router.back()
})
@@ -305,16 +303,9 @@ export struct ToolBarComp {
Button({ type: ButtonType.Normal, stateEffect: true }) {
Image($r('app.media.tick_thin')).height(24).width(24)
.onClick(() => {
// 退出键盘
inputMethod.getInputMethodController().stopInput();
// 保存笔记信息到数据库
this.controllerShow.runJavaScript({ script: "get_html_content()" })
this.editModel = false
// 清除定时器
if (time_id != undefined) {
LogUtil.info(TAG, "tick_thin, clearInterval time_id : " + time_id)
clearInterval(time_id)
}
})
}.width(42)
.height(42)
@@ -464,6 +455,32 @@ export struct EditNoteCompForPortrait {
.width(24)
.height(24)
.responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 })
.onClick(async () => {
LogUtil.info(TAG, 'startAbility start')
await globalThis.noteContext.startAbilityForResult({
parameters: { uri: "singleselect" },
bundleName: "com.ohos.photos",
abilityName: "com.ohos.photos.MainAbility",
}).then(v => {
let want = v['want'];
if (want != null && want != undefined) {
let param = want['parameters'];
let imageUri = ""
if (param != null && param != undefined) {
let uri = param['select-item-list'];
imageUri = uri;
}
// 拷贝
if (imageUri != null && imageUri != "") {
OperationUtils.copy(imageUri).then((uriPath) => {
var path = "file://" + uriPath
LogUtil.info(TAG, 'image uri is:' + path)
this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.insertImage('" + path + "')" })
})
}
}
});
})
Text($r("app.string.photo"))
.fontSize(10)
@@ -100,7 +100,6 @@ struct NoteOverViewComp {
.onClick(() => {
if (this.sectionStatus == 1) {
this.expandStatus = !this.expandStatus
AppStorage.SetOrCreate('ContinueExpand', this.expandStatus)
} else {
this.sectionStatus = (this.sectionStatus == 3 ? 2 : 3)
// save continue data
@@ -269,7 +268,6 @@ export struct NoteItemComp {
} else {
this.selectedNoteData = this.noteItem
this.chooseNote = true
AppStorage.SetOrCreate('ContinueChoose', this.chooseNote)
// save continue data
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
@@ -313,6 +311,7 @@ export struct NoteItemListComp {
@Consume @Watch('doSearch') inputKeyword: string
@Consume('SearchResultList') searchResultList: NoteData[]
@Consume('SelectedNoteData') selectedNoteData: NoteData
@Consume('PortraitModel') portraitModel:boolean
controllerShow: WebController
doSearch() {
@@ -325,7 +324,9 @@ export struct NoteItemListComp {
} else {
this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid)
}
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')" })
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())
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
@@ -419,6 +420,13 @@ export struct OperateNoteComp {
RdbStoreUtil.update(noteItem.toNoteObject(), predicates_note, null)
})
this.selectedNoteData = NoteUtil.getFirstNoteData(this.AllNoteArray, this.selectedFolderData.uuid)
// save continue data
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
LogUtil.info(TAG, "onMoveConfirm, set continue note success")
if(this.portraitModel == false) {
this.controllerShow.runJavaScript({script:"RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')" })
}
this.longpress = false
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
NoteUtil.unsetAllNotesChecked(this.CheckedNoteArray)
@@ -584,7 +592,6 @@ export struct AddNoteComp {
this.editModel = true
}
this.chooseNote = true
AppStorage.SetOrCreate('ContinueChoose', this.chooseNote)
// save continue data
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
@@ -660,6 +667,10 @@ export struct OperateNoteCompForPortrait {
RdbStoreUtil.update(noteItem.toNoteObject(), predicates_note, null)
})
this.selectedNoteData = NoteUtil.getFirstNoteData(this.AllNoteArray, this.selectedFolderData.uuid)
// save continue data
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
LogUtil.info(TAG, "onMoveConfirm, set continue note success")
this.longpress = false
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
NoteUtil.unsetAllNotesChecked(this.CheckedNoteArray)
+2 -2
View File
@@ -3,8 +3,8 @@
"bundleName": "com.ohos.note",
"vendor": "ohos",
"version": {
"code": 1000000,
"name": "1.0.0"
"code": 1000003,
"name": "1.0.3"
}
},
"deviceConfig": {},
@@ -43,7 +43,7 @@ export class OperationUtils {
var dir = context.filesDir
// 2、生成本地文件名
var time = new Date().getTime()
var imagePath = dir + "/" + time.toString().substr(5) + "_note" + numId + ".jpg"
var imagePath = dir + "/" + time.toString() + "_note" + ".jpg"
// 3、拷贝
await fileio.copyFile(fd, imagePath)
// 4、关闭安fd,Asset
@@ -25,6 +25,8 @@ import {TableSql, TableName, FolderTableColumn, NoteTableColumn, SysDefFolderUui
const TAG = "RdbStoreUtil"
const FileMaxSize: number = 20 * 1024 * 1024
/**
* db instance
*/
@@ -95,7 +97,6 @@ export default {
if (isContinue) {
let continueNote: string = AppStorage.Get('ContinueNote')
let continueSection = AppStorage.Get('ContinueSection')
let noteObj = JSON.parse(continueNote)
let noteData = new NoteData(noteObj.uuid, noteObj.title, noteObj.uuid, noteObj.folder_uuid,
noteObj.content_text, noteObj.content_img, noteObj.note_type, noteObj.is_top, noteObj.is_favorite,
@@ -103,16 +104,10 @@ export default {
// save img to FileDir
LogUtil.info(TAG, "createRdbStore, save img to FileDir")
let srcArray = this.getSrcFromHtml(noteObj.content_text)
srcArray.forEach((src: string) => {
let lastIndex = src.lastIndexOf('/')
LogUtil.info(TAG, " createRdbStore, lastIndex : " + lastIndex)
if (lastIndex != -1) {
let imgName = src.substring(lastIndex + 1)
this.writeToFileDir(context, imgName)
}
let imgNameArray = this.getImgNameFromHtml(noteData)
imgNameArray.forEach((imgName: string) => {
this.writeToFileDir(imgName)
})
LogUtil.info(TAG, "createRdbStore, save img to FileDir success")
// if not exit this note
let exist = false
@@ -147,7 +142,9 @@ export default {
AppStorage.SetOrCreate('Folder', FolderUtil.getFolderData(folderDataArray, folderUuid))
}
AppStorage.SetOrCreate('Note', noteData)
AppStorage.SetOrCreate<string>('ContinueNote', JSON.stringify(noteData.toNoteObject()))
AppStorage.SetOrCreate('Section', continueSection)
AppStorage.SetOrCreate<NoteData>('NewNote', noteData)
} else {
LogUtil.info(TAG, "createRdbStore, IsContinue false")
AppStorage.SetOrCreate('Folder', AppStorage.Get('AllFolderArray')[0])
@@ -218,7 +215,7 @@ export default {
AppStorage.SetOrCreate('AllNoteArray', noteDataArray)
LogUtil.info(TAG, "AppStorage[query] set AllFolderArray and AllNoteArray success")
// 迁移
// save continue data
let isContinue = AppStorage.Get<boolean>('IsContinue');
LogUtil.info(TAG, "initAppStorage, isContinue is " + isContinue)
if (isContinue) {
@@ -232,16 +229,10 @@ export default {
// save img to FileDir
LogUtil.info(TAG, "initAppStorage, save img to FileDir")
let srcArray = this.getSrcFromHtml(noteObj.content_text)
srcArray.forEach((src: string) => {
let lastIndex = src.lastIndexOf('/')
LogUtil.info(TAG, " initAppStorage, lastIndex : " + lastIndex)
if (lastIndex != -1) {
let imgName = src.substring(lastIndex + 1)
this.writeToFileDir(context, imgName)
}
let imgNameArray = this.getImgNameFromHtml(noteData)
imgNameArray.forEach((imgName: string) => {
this.writeToFileDir(imgName)
})
LogUtil.info(TAG, "initAppStorage, save img to FileDir success")
// if not exit this note
let exist = false
@@ -276,9 +267,11 @@ export default {
AppStorage.SetOrCreate('Folder', FolderUtil.getFolderData(folderDataArray, folderUuid))
}
AppStorage.SetOrCreate('Note', noteData)
AppStorage.SetOrCreate<string>('ContinueNote', JSON.stringify(noteData.toNoteObject()))
AppStorage.SetOrCreate('Section', continueSection)
AppStorage.SetOrCreate<NoteData>('NewNote', noteData)
} else {
LogUtil.info(TAG, "RdbStoreUtil initAppStorage, IsContinue false")
LogUtil.info(TAG, "initAppStorage, IsContinue false")
AppStorage.SetOrCreate('Folder', AppStorage.Get('AllFolderArray')[0])
let note = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray'), SysDefFolderUuid.AllNotes)
AppStorage.SetOrCreate('Note', note)
@@ -293,43 +286,87 @@ export default {
})
},
getSrcFromHtml(html: string): any{
LogUtil.info(TAG, "getSrcFromHtml")
getImgNameFromHtml(noteData: NoteData): any{
let newModuleName = "file://" + globalThis.noteContext.filesDir
let imgNameArray = []
let html = noteData.content_text
if (html == undefined || html == null || html == "") {
return imgNameArray
}
let imgReg = /<img[^>]+>/g
let srcReg = /src=[\'\"]?([^\'\"]*)[\'\"]?/i
let imgArray = html.match(imgReg)
let srcArray = []
if (imgArray != null) {
let hasFirstImg: boolean = false
for (let i = 0; i < imgArray.length; i++) {
let src = imgArray[i].match(srcReg)
srcArray.push(src[1])
if (src != null && src.length > 1) {
LogUtil.info(TAG, "getImgNameFromHtml, src[1] : " + src[1])
let lastIndex = src[1].lastIndexOf('/')
if (lastIndex != -1) {
let oldModuleName = src[1].substring(0, lastIndex)
let imgName = src[1].substring(lastIndex + 1)
noteData.content_text = noteData.content_text.replace(oldModuleName, newModuleName)
if (!hasFirstImg) {
noteData.content_img = newModuleName + "/" + imgName
hasFirstImg = true
}
imgNameArray.push(imgName)
}
}
}
}
return srcArray
return imgNameArray
},
writeToFileDir(context, fileName: string) {
writeToFileDir(fileName: string) {
LogUtil.info(TAG, "writeToFileDir fileName : " + fileName)
let distributedFilesDir = context.distributedFilesDir
let srcPath = distributedFilesDir + "/" + fileName
let desPath = globalThis.noteContext.filesDir + "/" + fileName
LogUtil.info(TAG, "desPath : " + desPath)
try {
fileio.accessSync(desPath)
LogUtil.info(TAG, "desPath has existed, return")
return
} catch (err) {
LogUtil.warn(TAG, "desPath has not existed, need to write")
}
let srcPath = globalThis.noteContext.distributedFilesDir + "/" + fileName
LogUtil.info(TAG, "srcPath : " + srcPath)
let size = fileio.statSync(srcPath).size
LogUtil.info(TAG, "srcPath size : " + size)
if (size > FileMaxSize) {
LogUtil.warn(TAG, "srcPath size more then FileMaxSize, return")
return
}
let srcFd
try {
srcFd = fileio.openSync(srcPath, 0o2, 0o666)
srcFd = fileio.openSync(srcPath, 0o0)
LogUtil.info(TAG, "open srcPath success : " + srcFd)
} catch (err) {
LogUtil.warn(TAG, "open srcPath failed : " + err)
return
}
let filesDir = context.filesDir
let desPath = filesDir + "/" + fileName
let desFd
try {
fileio.copyFileSync(srcFd, desPath)
LogUtil.info(TAG, "writeToFileDir, copyFile successfully")
desFd = fileio.openSync(desPath, 0o2 | 0o100, 0o400 | 0o200 | 0o040 | 0o020)
LogUtil.info(TAG, "open desPath success : " + srcFd)
} catch (err) {
LogUtil.warn(TAG, "writeToFileDir, copyFile failed : " + err)
LogUtil.warn(TAG, "open desPath failed : " + err)
return
}
let buf = new ArrayBuffer(size)
try {
let readNum = fileio.readSync(srcFd, buf)
LogUtil.info(TAG, "readNum : " + readNum)
let writeNum = fileio.writeSync(desFd, buf)
LogUtil.info(TAG, "writeNum : " + writeNum)
} catch (err) {
LogUtil.warn(TAG, "read or write error : " + err)
}
},
@@ -408,20 +445,18 @@ export default {
return new ohosDataRdb.RdbPredicates(tableName)
},
updataNoteImage(content):string {
let srcArray = this.getSrcFromHtml(content)
if(srcArray.length == 0) {
return ""
updataNoteImage(noteData: NoteData): string {
let content_img = ""
let imgNameArray = this.getImgNameFromHtml(noteData)
if (imgNameArray.length == 0) {
return content_img
}
if(srcArray[0] == './shuxue.png' || srcArray[0] == './cake.png') {
let lastIndex = srcArray[0].lastIndexOf('/')
LogUtil.info(TAG, "lastIndex : " + lastIndex)
let imgName = ""
if (lastIndex != -1) {
imgName = srcArray[0].substring(lastIndex + 1)
}
return "/res/" + imgName
if (imgNameArray[0] == 'shuxue.png' || imgNameArray[0] == 'cake.png') {
content_img = "/res/" + imgNameArray[0]
} else {
content_img = noteData.content_img
}
return srcArray[0]
LogUtil.info(TAG, "updataNoteImage, content_img : " + content_img)
return content_img
}
}
@@ -114,8 +114,8 @@ export default {
"title": "数学公式",
"uuid": "note1_uuid",
"folder_uuid": SysDefFolderUuid.UnClassified,
"content_text": '<p>好好学习,天天向上</p><div style="text-align:center;"><img src="./shuxue.png" height="700" style="border-radius:24px"/></div><br><br>',
"content_img": "/res/shuxue.png",
"content_text": '<text>好好学习,天天向上</text>',
"content_img": "",
"note_type": NoteType.SysDef,
"is_top": Top.Yes,
"is_favorite": Favorite.Yes,
@@ -146,12 +146,7 @@ export default {
"title": "旅游心得",
"uuid": "note3_uuid",
"folder_uuid": SysDefFolderUuid.Work,
"content_text": '<div style="line-height:1.4;"><p>出门在外首要是安全问题,不然命都没有了还谈什么?其次是身上的财物,要知道,你一到某地,身上的行李很容易被狼盯上。' +
'背着旅行袋的人到那里都是任人宰割的对象,所以不要完成全相信陌生人的话,也不要走行人稀少的小道,方便的话最好是将包裹就近寄存,免去这道危险。' +
'同时在身上相对安全的地方保留贴身的救命钱,狡兔三窟,千万不要将开心的旅游变成伤心的流浪!</p>' +
'<p>出门在外要想整个旅程无遗憾,关键是心态。首先要对即将到的目的地有一个正确的认识和恰当的期望。</p>' +
'<p>一般每个自然风景区旅游区都有着自己的特色,带著一种游九寨沟桂林山水的心情和期望去陕西的人肯定会失望而归。' +
'同样带着游西部的心情和期望去海南.桂林你也会觉得那里也没有什么,只不过山和水比别的地方特别一点。</p></div>',
"content_text": '<div style="line-height:1.4;"><text>要想整个旅程无遗憾,关键是心态,首先要对即将到的目的地有一个正确的认识和恰当的期望。</text></div>',
"content_img": "",
"note_type": NoteType.SysDef,
"is_top": Top.No,
@@ -172,11 +167,10 @@ export default {
'<span class="note-checkbox-txt">&nbsp;&nbsp;糖60g</span><br>' +
'<input name="checkbox" type="checkbox" onclick="onCheckChange(this)" class="note-checkbox">' +
'<span class="note-checkbox-txt">&nbsp;&nbsp;玉米油40g</span><br><div>' +
'<div style="margin-top:14px; margin-top:14px;"><text>&nbsp;&nbsp;&nbsp;&nbsp;1. 准备小盆打入三个鸡蛋,加盐加糖,蛋糕粉分两次加入蛋糊内。<br>' +
'&nbsp;&nbsp;&nbsp;&nbsp;2. 玉米油倒入碗里,再加入牛奶,用打蛋器打到完全融为一体,烤箱预热15分钟<br>' +
'&nbsp;&nbsp;&nbsp;&nbsp;3. 加入葡萄干、核桃仁,把蛋糕放进烤箱定时40分钟,取出即可食用。<br><br></text><div>' +
'<div style="text-align:center;"><img src="./cake.png" height="600" style="border-radius:24px"/></div><br><br>',
"content_img": "/res/cake.png",
'<div style="margin-top:14px; margin-top:14px;"><text>&nbsp;&nbsp;&nbsp;&nbsp;1. 添加鸡蛋、盐、糖、蛋糕粉<br>' +
'&nbsp;&nbsp;&nbsp;&nbsp;2. 加入玉米油、牛奶,烤箱预热15分钟<br>' +
'&nbsp;&nbsp;&nbsp;&nbsp;3. 加入葡萄干、核桃仁,烤箱定时40分钟<br><br></text><div>',
"content_img": "",
"note_type": NoteType.CusDef,
"is_top": Top.No,
"is_favorite": Favorite.Yes,
+2 -2
View File
@@ -3,8 +3,8 @@
"bundleName": "com.ohos.note",
"vendor": "ohos",
"version": {
"code": 1000000,
"name": "1.0.0"
"code": 1000003,
"name": "1.0.3"
}
},
"deviceConfig": {},
@@ -84,6 +84,10 @@
"name": "category_already_exist_font_color",
"value": "#FA2A2D"
},
{
"name": "category_already_exist_divider_color",
"value": "#FA2A2D"
},
{
"name": "create_folder_bg_color",
"value": "#FFFFFF"
@@ -158,7 +162,7 @@
},
{
"name": "Recently_delete_prompt_font_color",
"value": "#18181A"
"value": "#99182431"
},
{
"name": "Empty_page_font_color",
+2 -2
View File
@@ -3,8 +3,8 @@
"bundleName": "com.ohos.note",
"vendor": "ohos",
"version": {
"code": 1000000,
"name": "1.0.0"
"code": 1000003,
"name": "1.0.3"
}
},
"deviceConfig": {},
@@ -15,44 +15,31 @@
import Ability from '@ohos.application.Ability'
import fileio from '@ohos.fileio'
import inputMethod from '@ohos.inputMethod';
import inputMethod from '@ohos.inputMethod'
export default class MainAbility extends Ability {
private Tag = "Phone_Note_MainAbility"
private Tag = "MainAbility_Phone"
onCreate(want, launchParam) {
console.info(this.Tag + " onCreate, launchReason is " + launchParam.launchReason)
// 折叠状态
AppStorage.SetOrCreate<boolean>('Expand', false)
AppStorage.SetOrCreate<boolean>('Choose', false)
AppStorage.SetOrCreate<boolean>('Choose', true)
if (launchParam.launchReason == 3) {
// 获取对端的迁移数据
let continueNote: string = want.parameters["ContinueNote"]
let continueSection: number = want.parameters["ContinueSection"]
console.info(this.Tag + " continueSection : " + continueSection)
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
AppStorage.SetOrCreate<number>('ContinueSection', continueSection)
// 折叠状态
let continueExpand: boolean = want.parameters["ContinueExpand"]
let continueChoose: boolean = want.parameters["ContinueChoose"]
console.info(this.Tag + " continueExpand : " + continueExpand + " , continueChoose : " + continueChoose)
AppStorage.SetOrCreate<boolean>('Expand', continueExpand)
AppStorage.SetOrCreate<boolean>('Choose', continueChoose)
// 设置迁移标记
AppStorage.SetOrCreate<boolean>('IsContinue', true)
// 来自平板的迁移
if (continueExpand == undefined && continueChoose == undefined) {
console.info(this.Tag + " from tablet")
AppStorage.SetOrCreate<boolean>('Choose', true)
AppStorage.SetOrCreate<boolean>('Expand', false)
AppStorage.SetOrCreate('ContinueChoose', true)
// 获取对端的迁移数据
let continueNote: string = want.parameters["ContinueNote"]
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
// 来自手机的迁移
let continueChoose: boolean = want.parameters["ContinueChoose"]
if (continueChoose) {
console.info(this.Tag + " continue from phone")
}else{
AppStorage.SetOrCreate<boolean>('ContinueFromTablet', true)
console.info(this.Tag + " continue from tablet")
}
this.context.restoreWindowStage(null)
}
AppStorage.SetOrCreate<number>('openPhoto', 0)
AppStorage.SetOrCreate<number>('openPerm', 0)
globalThis.noteContext = this.context
}
@@ -78,4 +65,65 @@ export default class MainAbility extends Ability {
// 退出键盘
inputMethod.getInputMethodController().stopInput();
}
onContinue(wantParam: { [key: string]: any }) {
console.info(this.Tag + " onContinue")
// 获取本端的迁移数据
let continueNote = AppStorage.Get<string>('ContinueNote')
if (continueNote == undefined || continueNote == null) {
console.info(this.Tag + " onContinue, continueNote is error, default [0]")
continueNote = JSON.stringify(AppStorage.Get('AllNoteArray')[0].toNoteObject())
}
// 保存本端的迁移数据
wantParam["ContinueNote"] = continueNote
wantParam["ContinueChoose"] = true
// save img to DisFileDir
console.info(this.Tag + " onContinue, save img to DisFileDir")
let continueNoteObj = JSON.parse(continueNote)
let srcArray = this.getSrcFromHtml(continueNoteObj.content_text)
srcArray.forEach((src: string) => {
let lastIndex = src.lastIndexOf('/')
if (lastIndex != -1) {
let imgName = src.substring(lastIndex + 1)
this.writeToDisFileDir(imgName)
}
})
console.info(this.Tag + " onContinue end")
return true
}
getSrcFromHtml(html: string): any{
let srcArray = []
if (html == undefined || html == null || html == "") {
return srcArray
}
let imgReg = /<img[^>]+>/g
let srcReg = /src=[\'\"]?([^\'\"]*)[\'\"]?/i
let imgArray = html.match(imgReg)
if (imgArray != null) {
for (let i = 0; i < imgArray.length; i++) {
let src = imgArray[i].match(srcReg)
if (src != null && src.length > 1) {
srcArray.push(src[1])
}
}
}
return srcArray
}
writeToDisFileDir(fileName: string) {
console.info(this.Tag + " writeToDisFileDir, fileName : " + fileName)
let filesDir = this.context.filesDir
let srcPath = filesDir + "/" + fileName
let distributedFilesDir = this.context.distributedFilesDir
let desPath = distributedFilesDir + "/" + fileName
try {
fileio.copyFileSync(srcPath, desPath)
console.info(this.Tag + " onContinue, writeToDisFileDir, copyFile successfully")
} catch (err) {
console.warn(this.Tag + " onContinue, writeToDisFileDir, copyFile failed : " + err)
}
}
}
@@ -19,7 +19,8 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import {NoteHomePortraitComp} from './NoteHomePortrait.ets'
import {LogUtil} from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'
import RdbStoreUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/RdbStoreUtil.ets'
import inputMethod from '@ohos.inputMethod';
import inputMethod from '@ohos.inputMethod'
import router from '@system.router'
@Entry
@Component
@@ -27,14 +28,13 @@ export struct MyNoteHomeComp {
@StorageLink('DBQueryFinished') dBQueryFinished: number = 0
@Provide('PortraitModel') portraitModel: boolean = true
@Provide('RefreshFlag') refreshFlag: number = 0
private controllerShow: WebController = new WebController()
private context = getContext(this)
TAG = "MyNoteHomeComp"
TAG = "MyNoteHomeComp_Phone"
build() {
Flex() {
if (this.dBQueryFinished == 1) {
NoteHomePortraitComp({ controllerShow: this.controllerShow })
NoteHomePortraitComp()
}
}
.width('100%').height('100%')
@@ -52,39 +52,17 @@ export struct MyNoteHomeComp {
"ohos.permission.READ_MEDIA",
"ohos.permission.DISTRIBUTED_DATASYNC"
]
bundle.getApplicationInfo('com.ohos.note', 0, 100).then((appInfo) => {
let tokenId = appInfo.accessTokenId
let statusPromise: Array<Promise<number>> = []
let requestList: Array<string> = []
let atManager = abilityAccessCtrl.createAtManager()
for (let i = 0; i < permissionList.length; i++) {
statusPromise.push(atManager.verifyAccessToken(tokenId, permissionList[i]))
LogUtil.info(this.TAG, 'permissions need to require from user')
this.context.requestPermissionsFromUser(permissionList).then((data) => {
LogUtil.info(this.TAG, 'data permissions : ' + data.permissions)
LogUtil.info(this.TAG, 'data result: ' + data.authResults)
let sum = 0
for (let i = 0; i < data.authResults.length; i++) {
sum += data.authResults[i]
}
Promise.all(statusPromise).then((status) => {
for (let i = 0; i < status.length; i++) {
if (status[i] == abilityAccessCtrl.GrantStatus.PERMISSION_DENIED) {
requestList.push(permissionList[i])
}
}
if (requestList.length != 0) {
AppStorage.SetOrCreate<number>('openPerm', 1)
LogUtil.info(this.TAG, 'permissions need to require from user: ' + requestList)
this.context.requestPermissionsFromUser(requestList).then((data) => {
LogUtil.info(this.TAG, 'data permissions : ' + data.permissions)
LogUtil.info(this.TAG, 'data result: ' + data.authResults)
let sum = 0
for (let i = 0; i < data.authResults.length; i++) {
sum += data.authResults[i]
}
LogUtil.info(this.TAG, 'request permissions sum: ' + sum)
AppStorage.SetOrCreate<number>('openPerm', 0)
}, (err) => {
LogUtil.warn(this.TAG, 'failed to requestPermissionsFromUser : ' + err.code);
});
} else {
LogUtil.info(this.TAG, 'check all permissions are granted.')
}
})
LogUtil.info(this.TAG, 'request permissions sum: ' + sum)
}, (err) => {
LogUtil.warn(this.TAG, 'failed to requestPermissionsFromUser : ' + err.code);
})
let dbPath = this.context.databaseDir + "/db/note.db"
@@ -105,6 +83,15 @@ export struct MyNoteHomeComp {
onPageShow(): void{
LogUtil.info(this.TAG, "onPageShow")
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
// continue from tablet
let continueFromTablet = AppStorage.Get<boolean>('ContinueFromTablet')
LogUtil.info(this.TAG, "onPageShow, continueFromTablet : " + continueFromTablet)
let noteContentHomeExist = AppStorage.Get<boolean>('NoteContentHomeExist')
LogUtil.info(this.TAG, "onPageShow, noteContentHomeExist : " + noteContentHomeExist)
if (continueFromTablet && !noteContentHomeExist) {
router.push({ uri: 'pages/NoteContentHome' })
AppStorage.SetOrCreate<boolean>('ContinueFromTablet', false)
}
}
onBackPress():void{
@@ -15,19 +15,22 @@
import {NoteContentCompPortrait} from '../../../../../../../common/component/src/main/ets/default/NoteContentCompPortrait.ets'
import {LogUtil} from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'
import inputMethod from '@ohos.inputMethod';
import RdbStoreUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/RdbStoreUtil.ets'
@Entry
@Component
struct NoteContentHome {
@Provide('RefreshFlag') refreshFlag: number = 0
private controllerShow: WebController = new WebController()
TAG = "NoteContentHome"
@StorageLink('DBQueryFinished') dBQueryFinished: number = 0
TAG = "NoteContentHome_Phone"
build() {
// Note content display area
Flex({ direction: FlexDirection.Column, wrap: FlexWrap.Wrap, justifyContent: FlexAlign.Start }) {
NoteContentCompPortrait({ controllerShow: this.controllerShow })
if (this.dBQueryFinished == 1) {
NoteContentCompPortrait({ controllerShow: this.controllerShow })
}
}
.backgroundColor($r("app.color.notecontent_color_ffffff"))
.width('100%')
@@ -38,8 +41,16 @@ struct NoteContentHome {
LogUtil.info(this.TAG, "onBackPress")
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setInputEnabled(false)" })
this.controllerShow.runJavaScript({ script: "get_html_content()" })
// 退出键盘
inputMethod.getInputMethodController().stopInput();
}
aboutToAppear(): void{
LogUtil.info(this.TAG, "aboutToAppear")
let isContinue = AppStorage.Get<boolean>('IsContinue')
LogUtil.info(this.TAG, "aboutToAppear, isContinue : " + isContinue)
if (isContinue) {
RdbStoreUtil.initAppStorage(globalThis.noteContext)
}
AppStorage.SetOrCreate<boolean>('NoteContentHomeExist', true)
}
}
@@ -32,8 +32,7 @@ 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 = 1; // 表示分栏状态, 3表示三分栏, 2表示二分栏,1表示一分栏
@@ -41,7 +40,7 @@ export struct NoteHomePortraitComp {
@Provide('SelectedColor') selectedColor: string = circleColorArray[0];
@Provide('Longpress') longpress: boolean = false // 第二栏长按状态
// 分栏状态
// 分栏状态
@Provide('ExpandStatus') expandStatus: boolean = AppStorage.Get<boolean>('Expand') // 笔记本折叠展开状态
@Provide('ChooseNote') chooseNote: boolean = AppStorage.Get<boolean>('Choose') // 是否选择笔记进行打开
@@ -50,9 +49,8 @@ export struct NoteHomePortraitComp {
@Provide('InputKeyword') inputKeyword: string = '' // 搜索的字串
@Provide('SelectedAll') selectedAll:boolean = false;
@Provide('EditModel') editModel: boolean = false
controllerShow: WebController
TAG = "NoteHomeComp"
TAG = "NoteHomePortraitComp_Phone"
build() {
Stack({ alignContent: Alignment.Start }) {
@@ -100,6 +100,10 @@
"name": "category_already_exist_font_color",
"value": "#FA2A2D"
},
{
"name": "category_already_exist_divider_color",
"value": "#FA2A2D"
},
{
"name": "create_folder_bg_color",
"value": "#FFFFFF"
@@ -174,7 +178,7 @@
},
{
"name": "Recently_delete_prompt_font_color",
"value": "#18181A"
"value": "#99182431"
},
{
"name": "Empty_page_font_color",
@@ -4,9 +4,6 @@
<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">
@@ -57,7 +57,7 @@ RICH_EDITOR.setUnderline = function() {
document.execCommand('underline', false, null);
}
RICH_EDITOR.setStart = function () {
RICH_EDITOR.getListStyle = function () {
var selection, type;
if (window.getSelection) {
selection = getSelection();
@@ -70,12 +70,12 @@ RICH_EDITOR.setStart = function () {
if (child.nodeName == "OL") {
console.info('insertOrderedList')
document.execCommand('insertOrderedList', false, null);
break;
return child.style["list-style"]
}
if (child.nodeName == "UL") {
console.info('insertUnorderedList')
document.execCommand('insertUnorderedList', false, null);
break;
return child.style["list-style"]
}
if (child.parentNode) {
child = child.parentNode
@@ -85,11 +85,14 @@ RICH_EDITOR.setStart = function () {
}
}
}
RICH_EDITOR.setNumbers = function () {
RICH_EDITOR.setStart()
let listStyle = RICH_EDITOR.getListStyle()
if(listStyle == "decimal") {
return
}
document.execCommand('insertOrderedList', false, null);
var selection, type;
if (window.getSelection) {
@@ -115,7 +118,10 @@ RICH_EDITOR.setNumbers = function () {
}
RICH_EDITOR.setABC = function () {
RICH_EDITOR.setStart()
let listStyle = RICH_EDITOR.getListStyle()
if(listStyle == "lower-alpha") {
return
}
document.execCommand('insertOrderedList', false, null);
var selection, type;
if (window.getSelection) {
@@ -141,7 +147,10 @@ RICH_EDITOR.setABC = function () {
}
RICH_EDITOR.setBullets = function () {
RICH_EDITOR.setStart()
let listStyle = RICH_EDITOR.getListStyle()
if(listStyle == "disc") {
return
}
document.execCommand('insertUnorderedList', false, null);
var selection, type;
if (window.getSelection) {
@@ -167,7 +176,10 @@ RICH_EDITOR.setBullets = function () {
}
RICH_EDITOR.setSquare = function () {
RICH_EDITOR.setStart()
let listStyle = RICH_EDITOR.getListStyle()
if(listStyle == "square") {
return
}
document.execCommand('insertUnorderedList', false, null);
var selection, type;
if (window.getSelection) {
+2 -2
View File
@@ -3,8 +3,8 @@
"bundleName": "com.ohos.note",
"vendor": "ohos",
"version": {
"code": 1000000,
"name": "1.0.0"
"code": 1000003,
"name": "1.0.3"
}
},
"deviceConfig": {},
@@ -18,28 +18,27 @@ import fileio from '@ohos.fileio'
import inputMethod from '@ohos.inputMethod';
export default class MainAbility extends Ability {
private Tag = "Tablet_Note_MainAbility"
private Tag = "MainAbility_Tablet"
onCreate(want, launchParam) {
console.info(this.Tag + " onCreate, launchReason is " + launchParam.launchReason)
if (launchParam.launchReason == 3) {
// 设置迁移标记
AppStorage.SetOrCreate<boolean>('IsContinue', true)
// 获取对端的迁移数据
let continueNote: string = want.parameters["ContinueNote"]
let continueSection: number = want.parameters["ContinueSection"]
console.info(this.Tag + " continueSection : " + continueSection)
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
AppStorage.SetOrCreate<number>('ContinueSection', continueSection)
// 设置迁移标记
AppStorage.SetOrCreate<boolean>('IsContinue', true)
// 来自手机的迁移
let isChoose: boolean = want.parameters["ContinueChoose"]
console.info(this.Tag + " from phone, isChoose : " + isChoose)
AppStorage.SetOrCreate<boolean>('IsChoose', isChoose)
let continueChoose: boolean = want.parameters["ContinueChoose"]
if (continueChoose) {
console.info(this.Tag + " continue from phone")
AppStorage.SetOrCreate<boolean>('ContinueFromPhone', true)
}
this.context.restoreWindowStage(null)
}
AppStorage.SetOrCreate<number>('openPhoto', 0)
AppStorage.SetOrCreate<number>('openPerm', 0)
globalThis.noteContext = this.context
}
@@ -65,4 +64,73 @@ export default class MainAbility extends Ability {
// 退出键盘
inputMethod.getInputMethodController().stopInput();
}
onContinue(wantParam: { [key: string]: any }) {
console.info(this.Tag + " onContinue")
// 获取本端的迁移数据
let continueNote = AppStorage.Get<string>('ContinueNote')
if (continueNote == undefined || continueNote == null) {
console.info(this.Tag + " onContinue, continueNote is error, default [0]")
continueNote = JSON.stringify(AppStorage.Get('AllNoteArray')[0].toNoteObject())
}
let continueSection = AppStorage.Get<number>('ContinueSection')
if (continueSection == undefined || continueSection == null) {
console.info(this.Tag + " onContinue, continueSection is error, default 3")
continueSection = 3
}
console.info(this.Tag + " onContinue, continueSection : " + continueSection)
// 保存本端的迁移数据
wantParam["ContinueNote"] = continueNote
wantParam["ContinueSection"] = continueSection
// save img to DisFileDir
console.info(this.Tag + " onContinue, save img to DisFileDir")
let continueNoteObj = JSON.parse(continueNote)
let srcArray = this.getSrcFromHtml(continueNoteObj.content_text)
srcArray.forEach((src: string) => {
let lastIndex = src.lastIndexOf('/')
if (lastIndex != -1) {
let imgName = src.substring(lastIndex + 1)
this.writeToDisFileDir(imgName)
}
})
console.info(this.Tag + " onContinue end")
return true
}
getSrcFromHtml(html: string): any{
let srcArray = []
if (html == undefined || html == null || html == "") {
return srcArray
}
let imgReg = /<img[^>]+>/g
let srcReg = /src=[\'\"]?([^\'\"]*)[\'\"]?/i
let imgArray = html.match(imgReg)
if (imgArray != null) {
for (let i = 0; i < imgArray.length; i++) {
let src = imgArray[i].match(srcReg)
if (src != null && src.length > 1) {
console.info(this.Tag + " getSrcFromHtml, src[1] : " + src[1])
srcArray.push(src[1])
}
}
}
return srcArray
}
writeToDisFileDir(fileName: string) {
console.info(this.Tag + " writeToDisFileDir, fileName : " + fileName)
let filesDir = this.context.filesDir
let srcPath = filesDir + "/" + fileName
let distributedFilesDir = this.context.distributedFilesDir
let desPath = distributedFilesDir + "/" + fileName
try {
fileio.copyFileSync(srcPath, desPath)
console.info(this.Tag + " onContinue, writeToDisFileDir, copyFile successfully")
} catch (err) {
console.warn(this.Tag + " onContinue, writeToDisFileDir, copyFile failed : " + err)
}
}
}
@@ -30,7 +30,7 @@ export struct MyNoteHomeComp {
@Provide('RefreshFlag') refreshFlag: number = 0
private controllerShow: WebController = new WebController()
private context = getContext(this)
TAG = "MyNoteHomeComp"
TAG = "MyNoteHomeComp_Tablet"
build() {
Row() {
@@ -54,39 +54,17 @@ export struct MyNoteHomeComp {
"ohos.permission.READ_MEDIA",
"ohos.permission.DISTRIBUTED_DATASYNC"
]
bundle.getApplicationInfo('com.ohos.note', 0, 100).then((appInfo) => {
let tokenId = appInfo.accessTokenId
let statusPromise: Array<Promise<number>> = []
let requestList: Array<string> = []
let atManager = abilityAccessCtrl.createAtManager()
for (let i = 0; i < permissionList.length; i++) {
statusPromise.push(atManager.verifyAccessToken(tokenId, permissionList[i]))
LogUtil.info(this.TAG, 'permissions need to require from user')
this.context.requestPermissionsFromUser(permissionList).then((data) => {
LogUtil.info(this.TAG, 'data permissions : ' + data.permissions)
LogUtil.info(this.TAG, 'data result: ' + data.authResults)
let sum = 0
for (let i = 0; i < data.authResults.length; i++) {
sum += data.authResults[i]
}
Promise.all(statusPromise).then((status) => {
for (let i = 0; i < status.length; i++) {
if (status[i] == abilityAccessCtrl.GrantStatus.PERMISSION_DENIED) {
requestList.push(permissionList[i])
}
}
if (requestList.length != 0) {
AppStorage.SetOrCreate<number>('openPerm', 1)
LogUtil.info(this.TAG, 'permissions need to require from user: ' + requestList)
this.context.requestPermissionsFromUser(requestList).then((data) => {
LogUtil.info(this.TAG, 'data permissions : ' + data.permissions)
LogUtil.info(this.TAG, 'data result: ' + data.authResults)
let sum = 0
for (let i = 0; i < data.authResults.length; i++) {
sum += data.authResults[i]
}
LogUtil.info(this.TAG, 'request permissions sum: ' + sum)
AppStorage.SetOrCreate<number>('openPerm', 0)
}, (err) => {
LogUtil.warn(this.TAG, 'failed to requestPermissionsFromUser : ' + err.code);
});
} else {
LogUtil.info(this.TAG, 'check all permissions are granted.')
}
})
LogUtil.info(this.TAG, 'request permissions sum: ' + sum)
}, (err) => {
LogUtil.warn(this.TAG, 'failed to requestPermissionsFromUser : ' + err.code);
})
let dbPath = this.context.databaseDir + "/db/note.db"
@@ -107,8 +85,10 @@ export struct MyNoteHomeComp {
onPageShow(): void{
LogUtil.info(this.TAG, "onPageShow")
let currentNote = AppStorage.Get<NoteData>('NewNote')
if (currentNote != null) {
let needRefesh = AppStorage.Get<boolean>('needRefresh')
if (currentNote != null && needRefesh == true) {
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setHtml('" + currentNote.content_text + "')" })
AppStorage.SetOrCreate<boolean>('needRefresh',false)
}
this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
}
@@ -15,18 +15,21 @@
import {NoteContent} from '../../../../../../../common/component/src/main/ets/default/NoteContent.ets'
import {LogUtil} from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'
import inputMethod from '@ohos.inputMethod';
import RdbStoreUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/RdbStoreUtil.ets'
@Entry
@Component
struct NoteContentHome {
private controllerShow: WebController = new WebController()
TAG = "NoteContentHome"
@StorageLink('DBQueryFinished') dBQueryFinished: number = 0
TAG = "NoteContentHome_Tablet"
build() {
// Note content display area
Flex({ direction: FlexDirection.Column, wrap: FlexWrap.Wrap, justifyContent: FlexAlign.Start }) {
NoteContent({ controllerShow: this.controllerShow })
if (this.dBQueryFinished == 1) {
NoteContent({ controllerShow: this.controllerShow })
}
}
.backgroundColor($r("app.color.notecontent_color_ffffff"))
.width('100%')
@@ -37,8 +40,15 @@ struct NoteContentHome {
LogUtil.info(this.TAG, "onBackPress")
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setInputEnabled(false)" })
this.controllerShow.runJavaScript({ script: "get_html_content()" })
// 退出键盘
inputMethod.getInputMethodController().stopInput();
}
aboutToAppear(): void{
LogUtil.info(this.TAG, "aboutToAppear")
let isContinue = AppStorage.Get<boolean>('IsContinue')
LogUtil.info(this.TAG, "aboutToAppear, isContinue : " + isContinue)
if (isContinue) {
RdbStoreUtil.initAppStorage(globalThis.noteContext)
}
}
}
@@ -33,7 +33,7 @@ export struct NoteHomeComp {
@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')
@@ -50,12 +50,15 @@ export struct NoteHomeComp {
@Provide('Issave') issave: number = 0
controllerShow: WebController
TAG = "NoteHomeComp"
TAG = "NoteHomeComp_Tablet"
narrowWinListener = mediaquery.matchMediaSync('(width < 2000)')
onWinSizeChange(mediaQueryResult) {
if (this.sectionStatus != 1) {
this.sectionStatus = (mediaQueryResult.matches) ? 2 : 3
// save continue data
AppStorage.SetOrCreate<number>('ContinueSection', this.sectionStatus)
LogUtil.info(this.TAG, "onWinSizeChange, set continue section success")
}
}
@@ -121,11 +124,14 @@ export struct NoteHomeComp {
this.sectionStatus = AppStorage.Get('Section')
}
// continue from phone
let isChoose = AppStorage.Get<boolean>('IsChoose')
LogUtil.info(this.TAG, "aboutToAppear, isChoose : " + isChoose)
if (isChoose) {
this.sectionStatus = 1
let continueFromPhone = AppStorage.Get<boolean>('ContinueFromPhone')
LogUtil.info(this.TAG, "aboutToAppear, continueFromPhone : " + continueFromPhone)
if (continueFromPhone) {
this.sectionStatus = 3
}
// save continue data
AppStorage.SetOrCreate<number>('ContinueSection', this.sectionStatus)
LogUtil.info(this.TAG, "aboutToAppear, set continue section success")
}
aboutToDisappear(): void{
@@ -100,6 +100,10 @@
"name": "category_already_exist_font_color",
"value": "#FA2A2D"
},
{
"name": "category_already_exist_divider_color",
"value": "#FA2A2D"
},
{
"name": "create_folder_bg_color",
"value": "#FFFFFF"
@@ -174,7 +178,7 @@
},
{
"name": "Recently_delete_prompt_font_color",
"value": "#18181A"
"value": "#99182431"
},
{
"name": "Empty_page_font_color",
@@ -3,10 +3,10 @@
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 24 24" style="enable-background:new 0 0 24 24;" xml:space="preserve">
<style type="text/css">
.st0{fill-rule:evenodd;clip-rule:evenodd;fill:#007DFF;}
.st0{fill-rule:evenodd;clip-rule:evenodd;fill:#f86d05;}
.st1{filter:url(#filter-2);}
.st2{fill-rule:evenodd;clip-rule:evenodd;}
.st3{fill:none;stroke:#000000;stroke-opacity:5.000000e-02;}
.st3{fill:#f86d05;stroke:#000000;stroke-opacity:5.000000e-02;}
.st4{fill-rule:evenodd;clip-rule:evenodd;fill:#FFFFFF;}
</style>
<filter filterUnits="objectBoundingBox" height="160.0%" id="filter-2" width="160.0%" x="-30.0%" y="-20.0%">

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Public/ic_public_reduce</title>
<defs>
<path d="M2.96680416,4.02746433 C2.68362252,3.7442827 2.69149532,3.27728176 2.98438854,2.98438854 C3.27728176,2.69149532 3.7442827,2.68362252 4.02746433,2.96680416 L10.7801475,9.71948734 C11.0633291,10.002669 11.0554564,10.4696699 10.7625631,10.7625631 C10.4696699,11.0554564 10.002669,11.0633291 9.71948734,10.7801475 L2.96680416,4.02746433 Z M19.75,12.5 L19.7940682,12.5012732 C19.9384255,12.5096374 20.0718294,12.5588302 20.1829044,12.6374761 L20.2618461,12.7018051 L20.2946723,12.7344084 C20.4219425,12.8688111 20.5,13.0502899 20.5,13.25 C20.5,13.6296958 20.2178461,13.943491 19.8517706,13.9931534 L19.75,14 L15.0604628,13.9994628 L21.0331756,19.9725154 C21.3163684,20.2557082 21.3085047,20.7227182 21.0156115,21.0156115 C20.7227182,21.3085047 20.2557082,21.3163684 19.9725154,21.0331756 L13.9994628,15.0604628 L13.9987268,19.7940682 C13.9759152,20.18777 13.6494202,20.5 13.25,20.5 C13.090942,20.5 12.9434485,20.4504863 12.8220921,20.3660313 L12.7362032,20.2963663 L12.7036337,20.2637968 L12.6731019,20.2292885 C12.586627,20.1253173 12.5277267,19.9975979 12.5076256,19.857355 L12.5,19.75 L12.5,14.25 L12.5010148,14.1898376 C12.5310564,13.300598 13.2245361,12.5795925 14.1021145,12.5061604 L14.25,12.5 L19.75,12.5 Z M10.75,3.5 C10.909058,3.5 11.0565515,3.54951372 11.1779079,3.63396869 L11.2637968,3.7036337 L11.2963663,3.73620318 L11.3268981,3.77071147 C11.413373,3.87468274 11.4722733,4.0024021 11.4923744,4.14264502 L11.5,4.25 L11.4989852,9.81016244 C11.4689436,10.699402 10.7754639,11.4204075 9.89788549,11.4938396 L9.75,11.5 L4.2059318,11.4987268 C4.06157447,11.4903626 3.92817057,11.4411698 3.81709563,11.3625239 L3.73815385,11.2981949 L3.70532772,11.2655916 C3.5780575,11.1311889 3.5,10.9497101 3.5,10.75 C3.5,10.3703042 3.78215388,10.056509 4.14822944,10.0068466 L4.25,10 L9.2940682,9.99872683 C9.65496152,9.97781619 9.94739589,9.70172714 9.99362875,9.34820224 L10,9.25 L10,4.25 L10.0012732,4.2059318 C10.0240848,3.81222999 10.3505798,3.5 10.75,3.5 Z" id="path-1"></path>
</defs>
<g id="Public/ic_public_reduce" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<mask id="mask-2" fill="white">
<use xlink:href="#path-1"></use>
</mask>
<use id="形状" fill="#000000" fill-rule="nonzero" xlink:href="#path-1"></use>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.5 KiB

@@ -4,9 +4,6 @@
<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">
@@ -25,7 +25,7 @@ body {
table-layout: fixed;
width: 100%;
min-height:100%;
color: #333333;
color: #182431;
margin: 0;
}
@@ -38,7 +38,7 @@ body {
background-repeat: no-repeat;
background-position: center;
background-size: cover;
color: #333333;
color: #182431;
font-size:40px;
}
@@ -58,8 +58,8 @@ body {
}
.note-checkbox {
width: 23px;
height: 23px;
width: 36px;
height: 36px;
background-color: #ffffff;
border: 2px solid #555555;
-webkit-border-radius: 50%;
@@ -57,7 +57,7 @@ RICH_EDITOR.setUnderline = function() {
document.execCommand('underline', false, null);
}
RICH_EDITOR.setStart = function () {
RICH_EDITOR.getListStyle = function () {
var selection, type;
if (window.getSelection) {
selection = getSelection();
@@ -70,12 +70,12 @@ RICH_EDITOR.setStart = function () {
if (child.nodeName == "OL") {
console.info('insertOrderedList')
document.execCommand('insertOrderedList', false, null);
break;
return child.style["list-style"]
}
if (child.nodeName == "UL") {
console.info('insertUnorderedList')
document.execCommand('insertUnorderedList', false, null);
break;
return child.style["list-style"]
}
if (child.parentNode) {
child = child.parentNode
@@ -85,11 +85,14 @@ RICH_EDITOR.setStart = function () {
}
}
}
RICH_EDITOR.setNumbers = function () {
RICH_EDITOR.setStart()
let listStyle = RICH_EDITOR.getListStyle()
if(listStyle == "decimal") {
return
}
document.execCommand('insertOrderedList', false, null);
var selection, type;
if (window.getSelection) {
@@ -115,7 +118,10 @@ RICH_EDITOR.setNumbers = function () {
}
RICH_EDITOR.setABC = function () {
RICH_EDITOR.setStart()
let listStyle = RICH_EDITOR.getListStyle()
if(listStyle == "lower-alpha") {
return
}
document.execCommand('insertOrderedList', false, null);
var selection, type;
if (window.getSelection) {
@@ -141,7 +147,10 @@ RICH_EDITOR.setABC = function () {
}
RICH_EDITOR.setBullets = function () {
RICH_EDITOR.setStart()
let listStyle = RICH_EDITOR.getListStyle()
if(listStyle == "disc") {
return
}
document.execCommand('insertUnorderedList', false, null);
var selection, type;
if (window.getSelection) {
@@ -167,7 +176,10 @@ RICH_EDITOR.setBullets = function () {
}
RICH_EDITOR.setSquare = function () {
RICH_EDITOR.setStart()
let listStyle = RICH_EDITOR.getListStyle()
if(listStyle == "square") {
return
}
document.execCommand('insertUnorderedList', false, null);
var selection, type;
if (window.getSelection) {
Binary file not shown.