diff --git a/common/component/src/main/ets/default/CusDialogComp.ets b/common/component/src/main/ets/default/CusDialogComp.ets index 563ac53b13c6b7d87f591425558d1e94fcb2dc73..addde37ac313d6668643a591da793d2ee2d3eb3f 100644 --- a/common/component/src/main/ets/default/CusDialogComp.ets +++ b/common/component/src/main/ets/default/CusDialogComp.ets @@ -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() }) @@ -345,7 +348,7 @@ export struct NoteDataMoveDialog { export struct EditContentDialog { editContentDialogCtl: CustomDialogController confirm: (excuteJs: string) => void - @Consume('SelectedColor') selectedColor: string + @State selectFontColor: string = fontColorArray[0] @State inSetValue: number = 20 private circleColor: string private fontSize: number @@ -451,6 +454,7 @@ export struct EditContentDialog { Image($r('app.media.suojin_back')) .height(24) .width(24) + .responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 }) .onClick(() => { this.confirm("javascript:RICH_EDITOR.setOutdent()") }) @@ -541,10 +545,10 @@ export struct EditContentDialog { .fill(colorStr) Circle({ width: 12, height: 12 }) .fill($r("app.color.color_ffffff")) - .visibility(colorStr == this.selectedColor ? Visibility.Visible : Visibility.None) + .visibility(colorStr == this.selectFontColor ? Visibility.Visible : Visibility.None) }.onClick(() => { - this.selectedColor = colorStr - this.confirm("javascript:RICH_EDITOR.setTextColor('" + this.selectedColor + "')") + this.selectFontColor = colorStr + this.confirm("javascript:RICH_EDITOR.setTextColor('" + this.selectFontColor + "')") }) }, colorStr => colorStr) }.padding({ bottom: 11 }) @@ -668,13 +672,11 @@ export struct EditTitleDialog { export struct EditContentDialogPortrait { editContentDialogCtl: CustomDialogController; confirm: (excuteJs: string) => void - @Consume('SelectedColor') selectedColor: string; + @State selectFontColor: string = fontColorArray[0] @State inSetValue: number = 20 private circleColor: string private fontSize: number - - build() { Column() { Flex({ direction: FlexDirection.Row, wrap: FlexWrap.NoWrap, @@ -786,6 +788,7 @@ export struct EditContentDialogPortrait { Image($r('app.media.suojin_back')) .height(24) .width(24) + .responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 }) .onClick(() => { this.confirm("javascript:RICH_EDITOR.setOutdent()") }) @@ -852,10 +855,10 @@ export struct EditContentDialogPortrait { 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) + .visibility(colorStr == this.selectFontColor ? Visibility.Visible : Visibility.None) }.onClick(() => { - this.selectedColor = colorStr - this.confirm("javascript:RICH_EDITOR.setTextColor('" + this.selectedColor + "')") + this.selectFontColor = colorStr + this.confirm("javascript:RICH_EDITOR.setTextColor('" + this.selectFontColor + "')") }) }, colorStr => colorStr) } diff --git a/common/component/src/main/ets/default/FolderListComp.ets b/common/component/src/main/ets/default/FolderListComp.ets index 56199f62546d4ab29482a62e35fd34f3875b865e..5c5a4bbfce494895ee7263ea7ac111c57fa64a16 100644 --- a/common/component/src/main/ets/default/FolderListComp.ets +++ b/common/component/src/main/ets/default/FolderListComp.ets @@ -38,14 +38,14 @@ export struct FolderListComp { Image($r("app.media.suojin")) .height(24) .width(24) + .responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 }) .onClick(() => { if (this.sectionStatus == 1) { this.expandStatus = !this.expandStatus AppStorage.SetOrCreate('ContinueExpand', this.expandStatus) } else { this.sectionStatus = (this.sectionStatus == 3 ? 2 : 3) - // 迁移 - LogUtil.info(this.TAG, "FolderListComp, set continue section") + // save continue data AppStorage.SetOrCreate('ContinueSection', this.sectionStatus) LogUtil.info(this.TAG, "FolderListComp, set continue section success") } @@ -362,7 +362,9 @@ 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('ContinueNote', continueNote) diff --git a/common/component/src/main/ets/default/NoteContent.ets b/common/component/src/main/ets/default/NoteContent.ets new file mode 100644 index 0000000000000000000000000000000000000000..3a5c87388e62760783a66e732731140204a1e4b4 --- /dev/null +++ b/common/component/src/main/ets/default/NoteContent.ets @@ -0,0 +1,443 @@ +/* + * 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. + */ + +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 {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 {LogUtil} from '../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets' +import OperationUtils from '../../../../../../common/utils/src/main/ets/default/baseUtil/OperationUtils.ets' +import mediaquery from '@ohos.mediaquery' +import router from '@system.router'; +import inputMethod from '@ohos.inputMethod'; + +const TAG = "NoteContent" + +var timeID: number + +@Component +export struct NoteContent { + @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 + + noteContent = { + callbackhtml: (html) => { + LogUtil.info(TAG, 'note uuid is:' + this.selectedNoteData.uuid) + 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) + 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('NewNote', this.selectedNoteData) + // save continue data + let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) + AppStorage.SetOrCreate('ContinueNote', continueNote) + LogUtil.info(TAG, "callbackhtml, set continue note success") + }, + + callbackScheduledSave: (html) => { + LogUtil.info(TAG, 'callbackScheduledSave') + 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) + 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, 'callbackScheduledSave, update note success:' + this.selectedNoteData.uuid) + // save continue data + let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) + AppStorage.SetOrCreate('ContinueNote', continueNote) + LogUtil.info(TAG, 'callbackScheduledSave, set continue note success') + } + } + + 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() + + Web({ src: $rawfile('editor.html'), controller: this.controllerShow }) + .javaScriptAccess(true) + .onPageEnd((e) => { + if (this.editContentFlag == false) { + this.controllerShow.registerJavaScriptProxy({ + object: this.noteContent, + name: "callBackToApp", // html--> name.method + methodList: ["callbackhtml", "callbackScheduledSave"], + }) + LogUtil.info(TAG, "finish register") + this.controllerShow.refresh() + this.editContentFlag = true + } + LogUtil.info(TAG, "finish loadurl") + this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')" }) + }) + .zoomAccess(false) + .height(450) + .width('100%') + } + .margin({ top: 16 }) + .width(StyleConstants.PERCENTAGE_100) + .onClick(() => { + // 添加定时器: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) + } + + aboutToAppear(): void{ + LogUtil.info(TAG, "aboutToAppear") + } + + aboutToDisappear(): void{ + LogUtil.info(TAG, "aboutToDisappear") + } +} + +@Component +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({ + builder: EditContentDialog({ 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.NoWrap, + justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Image($r('app.media.zoom')) + .height(24) + .width(24) + .onClick(() => { + this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setInputEnabled(false)" }) + this.controllerShow.runJavaScript({ script: "get_html_content()" }) + // 清除定时器 + if (timeID != undefined) { + LogUtil.info(TAG, "zoom, clearInterval timeID : " + timeID) + clearInterval(timeID) + } + router.back() + }) + .visibility(this.selectedNoteData.is_deleted == Delete.Yes ? Visibility.None : Visibility.Visible) + + 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) + // 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) + }) + }.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()" }) + }) + }.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('openPhoto', 1) + await globalThis.noteContext.startAbilityForResult({ + parameters: { uri: "singleselect" }, + bundleName: "com.ohos.photos", + abilityName: "com.ohos.photos.MainAbility", + }) + .then(v => { + AppStorage.SetOrCreate('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; + } + // 拷贝 + 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) + .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')) + + + 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()" }) + // 退出键盘 + inputMethod.getInputMethodController().stopInput(); + }) + }.width(42) + .height(42) + .borderRadius(8) + .backgroundColor($r('app.color.color_ffffff')) + }.width(274) + } + } + .width(StyleConstants.PERCENTAGE_100) + .height(80) + } +} + +@Component +export struct NoteContentOverViewComp { + @Consume('SelectedNoteData') selectedNoteData: NoteData + @StorageLink('AllFolderArray') AllFolderArray: FolderData[] = [] + @StorageLink('CheckedNoteArray') CheckedNoteArray: NoteData[] = [] + 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) + // save continue data + let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) + AppStorage.SetOrCreate('ContinueNote', continueNote) + LogUtil.info(TAG, "NoteContentOverViewComp confirm, set continue note success") + } + + @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 + 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('ContinueNote', continueNote) + LogUtil.info(TAG, "NoteContentOverViewComp MenuBuilder, set continue note success") + }) + }, 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 }) + .fontColor($r("app.color.modified_time_font_color")) + 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) + } + .opacity(this.selectedNoteData.is_deleted == Delete.Yes ? 0.4 : 1) + .width(StyleConstants.PERCENTAGE_100) + .height(80) + } +} + +@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) + } +} \ No newline at end of file diff --git a/common/component/src/main/ets/default/NoteContentComp.ets b/common/component/src/main/ets/default/NoteContentComp.ets index 99bb279df3c2e79c583bf0b9b8bf2e1927752d77..54bc4306f57cd5049d596c2fba347e17b82d8eab 100644 --- a/common/component/src/main/ets/default/NoteContentComp.ets +++ b/common/component/src/main/ets/default/NoteContentComp.ets @@ -27,6 +27,7 @@ import featureAbility from '@ohos.ability.featureAbility' import {LogUtil} from '../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets' import OperationUtils from '../../../../../../common/utils/src/main/ets/default/baseUtil/OperationUtils.ets' import mediaquery from '@ohos.mediaquery' +import inputMethod from '@ohos.inputMethod'; const TAG = "NoteContentComp" @@ -42,6 +43,7 @@ export struct NoteContentComp { @Consume('EditModel') editModel: boolean @Consume('SectionStatus') sectionStatus: number @Consume('LastSectionStatus') lastSectionStatus: number + @Consume('Issave') issave: number controllerShow: WebController private editContentFlag = false @State uri1: string = "" @@ -74,22 +76,13 @@ 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.uuid) - // save continue data - let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) - AppStorage.SetOrCreate('ContinueNote', continueNote) - LogUtil.info(TAG, "callbackhtml, set continue note success") - // 删除空白笔记 - 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 + "')"}) - } this.sectionStatus = this.lastSectionStatus this.sectionStatus = mediaquery.matchMediaSync('(width < 2000)').matches ? 2 : 3 // save continue data - LogUtil.info(TAG, "callbackhtmlSave, set continue section") + let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) + AppStorage.SetOrCreate('ContinueNote', continueNote) AppStorage.SetOrCreate('ContinueSection', this.sectionStatus) - LogUtil.info(TAG, "callbackhtmlSave, set continue section success") + LogUtil.info(TAG, "callbackhtmlSave, set continue note and section success") return "AceString" }, @@ -120,7 +113,7 @@ export struct NoteContentComp { } Column() { - NoteContentOverViewComp() + NoteContentOverViewComp({ controllerShow: this.controllerShow }) Text(this.refreshFlag.toString()).visibility(Visibility.None) Text(this.AllNoteArray.length.toString()).visibility(Visibility.None) // 用于强制刷新使用 @@ -152,12 +145,15 @@ export struct NoteContentComp { .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('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()" }) @@ -166,6 +162,8 @@ export struct NoteContentComp { // save continue data AppStorage.SetOrCreate('ContinueSection', this.sectionStatus) LogUtil.info(TAG, "set continue section success") + this.editModel = !this.editModel + AppStorage.SetOrCreate('IsContinue', false) } }) } @@ -192,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, @@ -222,7 +223,13 @@ 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.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) + // save continue data + let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) + AppStorage.SetOrCreate('ContinueNote', continueNote) + LogUtil.info(TAG, "NoteContentOverViewComp, MenuBuilder, set continue note success") }) }, noteItem => noteItem.uuid) }.listDirection(Axis.Vertical) @@ -287,6 +294,7 @@ export struct ToolBarComp { @Consume('PortraitModel') portraitModel: boolean @StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray') @Consume('EditModel') editModel: boolean + @Consume('Issave') issave: number controllerShow: WebController private context = getContext(this) @@ -362,8 +370,7 @@ export struct ToolBarComp { } } this.editModel = !this.editModel - // 迁移 - LogUtil.info(TAG, "ToolBarComp, set continue section") + // save continue data AppStorage.SetOrCreate('ContinueSection', this.sectionStatus) LogUtil.info(TAG, "ToolBarComp, set continue section success") }) @@ -409,6 +416,8 @@ export struct ToolBarComp { .onClick(() => { // 清单 this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.setTodo()" }) + // 退出键盘 + inputMethod.getInputMethodController().stopInput(); }) }.width(42) .height(42) @@ -420,11 +429,9 @@ export struct ToolBarComp { .height(24) .width(24) .onClick(() => { - if (this.portraitModel) { - this.editContentDialogCtl.open() - } else { - this.editContentDialogCtl.open() - } + // 退出键盘 + inputMethod.getInputMethodController().stopInput(); + this.editContentDialogCtl.open() }) }.width(42) .height(42) @@ -432,67 +439,58 @@ export struct ToolBarComp { .backgroundColor($r('app.color.color_ffffff')) Button({ type: ButtonType.Normal, stateEffect: true }) { - Image($r('app.media.picture_white')).height(24).width(24) - .onClick(async () => { - LogUtil.info(TAG, 'startAbility start') - AppStorage.SetOrCreate('openPhoto', 1) - await globalThis.noteContext.startAbilityForResult({ - parameters: { uri: "singleselect" }, - bundleName: "com.ohos.photos", - abilityName: "com.ohos.photos.MainAbility", - }) - .then(v => { - AppStorage.SetOrCreate('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; - } - // 拷贝 - 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 + "')"}) - }) - } - }); - }) + 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')) + 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')) + Image($r('app.media.todo')) .height(24) .width(24) .onClick(() => { - - this.controllerShow.runJavaScript({ script: "RICH_EDITOR.undo()" }) + // 退出键盘 + 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.todo')) + Image($r('app.media.tick_thick')) .height(24) .width(24) + .fillColor(this.issave == 0 ? Color.Black : Color.Grey) .onClick(() => { - this.controllerShow.runJavaScript({ script: "RICH_EDITOR.redo()" }) + // 保存笔记信息到数据库 + 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 + // 退出键盘 + inputMethod.getInputMethodController().stopInput(); }) }.width(42) .height(42) diff --git a/common/component/src/main/ets/default/NoteContentCompPortrait.ets b/common/component/src/main/ets/default/NoteContentCompPortrait.ets index 22aaa566eb7ddcd4b3d9e84b4f4bc79af2d2d9a9..52b1d39934e4cd422727beb78a53f72f5abec000 100644 --- a/common/component/src/main/ets/default/NoteContentCompPortrait.ets +++ b/common/component/src/main/ets/default/NoteContentCompPortrait.ets @@ -17,7 +17,8 @@ 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 {EditContentDialogPortrait, DeleteDialog, EditTitleDialog} from './CusDialogComp.ets' import FolderUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/FolderUtil.ets' @@ -26,25 +27,22 @@ import prompt from '@system.prompt' import featureAbility from '@ohos.ability.featureAbility'; import {LogUtil} from '../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets' import OperationUtils from '../../../../../../common/utils/src/main/ets/default/baseUtil/OperationUtils.ets' +import router from '@system.router' +import inputMethod from '@ohos.inputMethod'; -var timeId : number +var time_id: number const TAG = "NoteContentCompPortrait" // Note content component @Component export struct NoteContentCompPortrait { - @Consume('SelectedNoteData') selectedNoteData: NoteData; + @Provide('SelectedNoteData') selectedNoteData: NoteData = AppStorage.Get("NewNote") + @Provide('SelectedFolderData') selectedFolderData: FolderData = AppStorage.Get("NewFolder") @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() + @Provide('EditModel') editModel: boolean = false + controllerShow: WebController private editContentFlag = false - @State uri1: string = ""; - private context = getContext(this) noteContent = { callbackhtml: (html) => { LogUtil.info(TAG, 'note uuid is:' + this.selectedNoteData.uuid) @@ -60,7 +58,6 @@ export struct NoteContentCompPortrait { let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) AppStorage.SetOrCreate('ContinueNote', continueNote) LogUtil.info(TAG, "callbackhtml, set continue note success") - return "AceString" }, callbackScheduledSave: (html) => { @@ -78,7 +75,6 @@ export struct NoteContentCompPortrait { AppStorage.SetOrCreate('ContinueNote', continueNote) LogUtil.info(TAG, 'callbackScheduledSave, set continue note success') } - } build() { @@ -91,8 +87,6 @@ export struct NoteContentCompPortrait { 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) @@ -101,15 +95,13 @@ export struct NoteContentCompPortrait { this.controllerShow.registerJavaScriptProxy({ object: this.noteContent, name: "callBackToApp", // html--> name.method - methodList: ["callbackhtml","callbackScheduledSave"], - }); + methodList: ["callbackhtml", "callbackScheduledSave"], + }) LogUtil.info(TAG, "finish register") this.controllerShow.refresh() this.editContentFlag = true } LogUtil.info(TAG, "finish loadurl") - // 初次进入预览模式 - this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setInputEnabled(false)" }) this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')" }) @@ -118,23 +110,19 @@ export struct NoteContentCompPortrait { .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 // 添加定时器:3s自动保存 - timeId = setInterval(() => { + time_id = setInterval(() => { this.controllerShow.runJavaScript({ script: "scheduled_save_content()" }) }, 3000) - LogUtil.info(TAG, "NoteContentCompPortrait, setInterval timeId : " + timeId) + LogUtil.info(TAG, "setInterval time_id : " + time_id) + this.editModel = true }) + .margin({ top: 16 }) + .width(StyleConstants.PERCENTAGE_100) } .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() @@ -142,14 +130,21 @@ export struct NoteContentCompPortrait { .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('SectionStatus') sectionStatus: number editTitleDialogCtl: CustomDialogController = new CustomDialogController({ builder: EditTitleDialog({ confirm: this.confirm.bind(this), dialogType: 0 }), alignment: DialogAlignment.Center, @@ -163,6 +158,10 @@ 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) + // save continue data + let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) + AppStorage.SetOrCreate('ContinueNote', continueNote) + LogUtil.info(TAG, 'NoteContentOverViewComp, MenuBuilder, set continue note success') } @Builder MenuBuilder() { @@ -174,6 +173,13 @@ export struct NoteContentOverViewComp { } .onClick(() => { this.selectedNoteData.folder_uuid = item.uuid + 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('ContinueNote', continueNote) + LogUtil.info(TAG, 'MenuBuilder, set continue note success') }) }, noteItem => noteItem.uuid) }.listDirection(Axis.Vertical) @@ -193,11 +199,14 @@ export struct NoteContentOverViewComp { .onClick(() => { this.editTitleDialogCtl.open() }) - }.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 }) + .fontColor($r("app.color.modified_time_font_color")) Row() { Text(FolderUtil.getFolderText(FolderUtil.getFolderData(AppStorage.Get('AllFolderArray'), this.selectedNoteData.folder_uuid))) .fontSize(12) @@ -213,6 +222,7 @@ export struct NoteContentOverViewComp { .bindMenu(this.MenuBuilder) }.alignItems(VerticalAlign.Top).height(40).width(StyleConstants.PERCENTAGE_100) } + .opacity(this.selectedNoteData.is_deleted == Delete.Yes ? 0.4 : 1) .width(StyleConstants.PERCENTAGE_100) .height(80) } @@ -220,36 +230,28 @@ export struct NoteContentOverViewComp { @Component export struct ToolBarComp { - @Consume('SelectedNoteData') selectedNoteData: NoteData; - @Consume('RefreshFlag') refreshFlag: number - @Consume('SectionStatus') sectionStatus: number + @Consume('SelectedNoteData') selectedNoteData: NoteData @Consume('SelectedFolderData') selectedFolderData: FolderData - @Consume('ChooseNote') chooseNote: boolean - @Consume('PortraitModel') portraitModel: boolean - @StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray') @Consume('EditModel') editModel: boolean + @StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray') 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) + Image($r('app.media.back')) + .height(24) + .width(24) + .responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 }) .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 - AppStorage.SetOrCreate('ContinueChoose', this.chooseNote) // 清除定时器 - if (timeId != undefined) { - LogUtil.info(TAG, "back, clearInterval timeId : " + timeId) - clearInterval(timeId) + if (time_id != undefined) { + LogUtil.info(TAG, "back, clearInterval time_id : " + time_id) + clearInterval(time_id) } + router.back() }) if (this.editModel == false) { @@ -258,19 +260,17 @@ export struct ToolBarComp { .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) - // 迁移 - LogUtil.info(TAG, "ToolBarComp, set continue note") - let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) - AppStorage.SetOrCreate('ContinueNote', continueNote) - LogUtil.info(TAG, "ToolBarComp, set continue note success") } + // save continue data + let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) + AppStorage.SetOrCreate('ContinueNote', continueNote) + LogUtil.info(TAG, 'ToolBarComp, set continue note success') }) }.width(36) .visibility(this.selectedNoteData.is_deleted == Delete.Yes ? Visibility.None : Visibility.Visible) @@ -279,6 +279,8 @@ export struct ToolBarComp { Button({ type: ButtonType.Normal, stateEffect: true }) { Image($r('app.media.undo')).height(24).width(24) .onClick(() => { + // 退出键盘 + inputMethod.getInputMethodController().stopInput(); this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.undo()" }) }) }.width(42) @@ -289,6 +291,8 @@ export struct ToolBarComp { Button({ type: ButtonType.Normal, stateEffect: true }) { Image($r('app.media.todo')).height(24).width(24) .onClick(() => { + // 退出键盘 + inputMethod.getInputMethodController().stopInput(); this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.redo()" }) }) }.width(42) @@ -301,17 +305,9 @@ export struct ToolBarComp { .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.controllerShow.runJavaScript({ script: "RICH_EDITOR.setInputEnabled(false)" }) this.editModel = false - // 清除定时器 - if (timeId != undefined) { - LogUtil.info(TAG, "tick_thin, clearInterval timeId : " + timeId) - clearInterval(timeId) - } + // 退出键盘 + inputMethod.getInputMethodController().stopInput(); }) }.width(42) .height(42) @@ -334,8 +330,6 @@ export struct DeleteNoteComp { @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, @@ -358,10 +352,6 @@ export struct DeleteNoteComp { 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 - AppStorage.SetOrCreate('ContinueChoose', this.chooseNote) } build() { @@ -370,6 +360,7 @@ export struct DeleteNoteComp { Image($r('app.media.delete')) .width(24) .height(24) + .responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 }) .onClick(() => { this.noteDataDeleteDialogCtlBottom.open() }) @@ -384,13 +375,12 @@ export struct DeleteNoteComp { Image($r('app.media.recover')) .width(24) .height(24) + .responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 }) .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 - AppStorage.SetOrCreate('ContinueChoose', this.chooseNote) // update note to db let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable) predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid) @@ -405,7 +395,7 @@ export struct DeleteNoteComp { } .width(360) .height(56) - .visibility(this.selectedNoteData.is_deleted == Delete.Yes && this.portraitModel == true ? + .visibility(this.selectedNoteData.is_deleted == Delete.Yes ? Visibility.Visible : Visibility.None) } } @@ -415,10 +405,7 @@ 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({ @@ -438,6 +425,7 @@ export struct EditNoteCompForPortrait { Image($r('app.media.circle_tick')) .width(24) .height(24) + .responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 }) .onClick(() => { // 清单 this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.setTodo()" }) @@ -453,6 +441,7 @@ export struct EditNoteCompForPortrait { Image($r('app.media.font_style')) .width(24) .height(24) + .responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 }) .onClick(() => { this.editContentDialogCtl.open() }) @@ -467,6 +456,7 @@ export struct EditNoteCompForPortrait { Image($r('app.media.picture_white')) .width(24) .height(24) + .responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 }) Text($r("app.string.photo")) .fontSize(10) @@ -512,7 +502,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 }) } @@ -520,4 +512,4 @@ struct NoteDataMoveItemComp { .height(56) .visibility(FolderUtil.isFolderMoveIn(this.folderItem) ? Visibility.Visible : Visibility.None) } -} +} \ No newline at end of file diff --git a/common/component/src/main/ets/default/NoteListComp.ets b/common/component/src/main/ets/default/NoteListComp.ets index 6a8d73e907e0ad2472857d81e51189985c455721..990429df48f3cc26c6742b54740401d408651b19 100644 --- a/common/component/src/main/ets/default/NoteListComp.ets +++ b/common/component/src/main/ets/default/NoteListComp.ets @@ -25,9 +25,21 @@ import FolderUtil from '../../../../../../common/utils/src/main/ets/default/base import StyleConstants from '../../../../../../common/utils/src/main/ets/default/constants/StyleConstants.ets' import SearchModel from '../../../../../../common/utils/src/main/ets/default/model/searchModel/SearchModel.ets' import {LogUtil} from '../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets' +import router from '@system.router'; const TAG = "NoteListComp" +async function routePage() { + let options = { + uri: 'pages/NoteContentHome' + } + try { + await router.push(options) + } catch (err) { + LogUtil.info(TAG, "fail callback") + } +} + // Note list component @Component export struct NoteListComp { @@ -82,6 +94,7 @@ struct NoteOverViewComp { Image($r("app.media.suojin_back")) .height(24) .width(24) + .responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 }) .margin({ right: this.sectionStatus != 3 ? 24 : 0 }) // 两分栏时缩进图片与右边有个24的间距 .visibility(this.sectionStatus != 3 ? Visibility.Visible : Visibility.None) .onClick(() => { @@ -90,8 +103,7 @@ struct NoteOverViewComp { AppStorage.SetOrCreate('ContinueExpand', this.expandStatus) } else { this.sectionStatus = (this.sectionStatus == 3 ? 2 : 3) - // 迁移 - LogUtil.info(TAG, "NoteOverViewComp, set continue section") + // save continue data AppStorage.SetOrCreate('ContinueSection', this.sectionStatus) LogUtil.info(TAG, "NoteOverViewComp, set continue section success") } @@ -124,6 +136,7 @@ struct NoteOverViewComp { Image($r("app.media.cross")) .height(24) .width(24) + .responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 }) .onClick(() => { this.longpress = false this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0) @@ -265,6 +278,11 @@ export struct NoteItemComp { if(this.portraitModel == false) { this.controllerShow.runJavaScript({script:"RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')" }) } + if(this.portraitModel == true) { + AppStorage.SetOrCreate('NewNote', this.selectedNoteData) + AppStorage.SetOrCreate('NewFolder', this.selectedFolderData) + routePage() + } this.selectedAll = this.CheckedNoteArray.length == NoteUtil.getNoteDataArray(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid).length this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0) @@ -295,6 +313,7 @@ export struct NoteItemListComp { @Consume @Watch('doSearch') inputKeyword: string @Consume('SearchResultList') searchResultList: NoteData[] @Consume('SelectedNoteData') selectedNoteData: NoteData + @Consume('PortraitModel') portraitModel:boolean controllerShow: WebController doSearch() { @@ -307,7 +326,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('ContinueNote', continueNote) @@ -401,6 +422,9 @@ export struct OperateNoteComp { RdbStoreUtil.update(noteItem.toNoteObject(), predicates_note, null) }) this.selectedNoteData = NoteUtil.getFirstNoteData(this.AllNoteArray, this.selectedFolderData.uuid) + 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) @@ -542,6 +566,7 @@ export struct AddNoteComp { .width(24) .height(24) .margin({ right: 12 }) + .responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 }) .onClick(() => { let noteData if (this.selectedFolderData.uuid == SysDefFolderUuid.AllNotes) { @@ -555,24 +580,22 @@ export struct AddNoteComp { LogUtil.info(TAG, 'insert new note is:' + noteData.uuid) this.selectedNoteData = noteData - if (this.sectionStatus != 1) { - this.lastSectionStatus = this.sectionStatus - this.sectionStatus = 1 - this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setInputEnabled(true)" }) - } else { - this.sectionStatus = this.lastSectionStatus + AppStorage.SetOrCreate('NewNote', noteData) + if (this.portraitModel == false) { + 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 + "')" }) + if (this.portraitModel == true) { + this.editModel = true } - this.editModel = true this.chooseNote = true AppStorage.SetOrCreate('ContinueChoose', this.chooseNote) // save continue data let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) AppStorage.SetOrCreate('ContinueNote', continueNote) - AppStorage.SetOrCreate('ContinueSection', this.sectionStatus) - LogUtil.info(TAG, "addNote, set continue note and section success") + LogUtil.info(TAG, "addNote, set continue note success") + routePage() }) .visibility(this.longpress || this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ? Visibility.None : Visibility.Visible) } @@ -588,6 +611,7 @@ export struct SearchComp { Image($r('app.media.back')) .width(24) .height(24) + .responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 }) .margin({ right: this.search ? 16 : 0 }) .visibility(this.search ? Visibility.Visible : Visibility.None) .onClick(() => { @@ -690,6 +714,7 @@ export struct OperateNoteCompForPortrait { Image($r("app.media.set_top")) .width(24) .height(24) + .responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 }) .onClick(() => { this.CheckedNoteArray.forEach((noteItem) => { noteItem.is_top = (noteItem.is_top == Top.Yes) ? Top.No : Top.Yes @@ -715,6 +740,7 @@ export struct OperateNoteCompForPortrait { Image($r('app.media.delete')) .width(24) .height(24) + .responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 }) .onClick(() => { this.noteDataDeleteDialogCtlBottom.open() }) @@ -732,6 +758,7 @@ export struct OperateNoteCompForPortrait { Image($r('app.media.move')) .width(24) .height(24) + .responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 }) .onClick(() => { this.noteDataMoveDialogCtlBottom.open() }) @@ -751,6 +778,7 @@ export struct OperateNoteCompForPortrait { Image($r('app.media.recover')) .width(24) .height(24) + .responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 }) .onClick(() => { this.CheckedNoteArray.forEach((noteItem) => { noteItem.is_deleted = Delete.No @@ -779,6 +807,7 @@ export struct OperateNoteCompForPortrait { Image($r('app.media.check_all')) .width(24) .height(24) + .responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 }) .onClick(() => { if (this.CheckedNoteArray.length < NoteUtil.getNoteDataArray(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid) diff --git a/common/utils/src/main/ets/default/baseUtil/RdbStoreUtil.ets b/common/utils/src/main/ets/default/baseUtil/RdbStoreUtil.ets index 736ae5227eb29e11c1364602cf9e0a4d89dfd9ca..69faf60ce0cb59b291ddc62dc96e0f9328020473 100644 --- a/common/utils/src/main/ets/default/baseUtil/RdbStoreUtil.ets +++ b/common/utils/src/main/ets/default/baseUtil/RdbStoreUtil.ets @@ -103,7 +103,7 @@ export default { // save img to FileDir LogUtil.info(TAG, "createRdbStore, save img to FileDir") - let srcArray = this.getSrcFromHtml(decodeURI(noteObj.content_text)) + let srcArray = this.getSrcFromHtml(noteObj.content_text) srcArray.forEach((src: string) => { let lastIndex = src.lastIndexOf('/') LogUtil.info(TAG, " createRdbStore, lastIndex : " + lastIndex) @@ -232,7 +232,7 @@ export default { // save img to FileDir LogUtil.info(TAG, "initAppStorage, save img to FileDir") - let srcArray = this.getSrcFromHtml(decodeURI(noteObj.content_text)) + let srcArray = this.getSrcFromHtml(noteObj.content_text) srcArray.forEach((src: string) => { let lastIndex = src.lastIndexOf('/') LogUtil.info(TAG, " initAppStorage, lastIndex : " + lastIndex) @@ -294,7 +294,7 @@ export default { }, getSrcFromHtml(html: string): any{ - LogUtil.info(TAG, "getSrcFromHtml, html : " + html) + LogUtil.info(TAG, "getSrcFromHtml") let imgReg = /]+>/g let srcReg = /src=[\'\"]?([^\'\"]*)[\'\"]?/i let imgArray = html.match(imgReg) @@ -302,11 +302,9 @@ export default { if (imgArray != null) { for (let i = 0; i < imgArray.length; i++) { let src = imgArray[i].match(srcReg) - LogUtil.info(TAG, "getSrcFromHtml, src[1] : " + src[1]) srcArray.push(src[1]) } } - LogUtil.info(TAG, "getSrcFromHtml, srcArray : " + srcArray) return srcArray }, @@ -411,12 +409,11 @@ export default { }, updataNoteImage(content):string { - let srcArray = this.getSrcFromHtml(decodeURI(content)) - LogUtil.info(TAG, "getSrcFromHtml, srcArray : " + srcArray) + let srcArray = this.getSrcFromHtml(content) if(srcArray.length == 0) { return "" } - if(srcArray[0] == './shuxue.png' || srcArray[0] == './lvyou.png' || srcArray[0] == './cake.png') { + if(srcArray[0] == './shuxue.png' || srcArray[0] == './cake.png') { let lastIndex = srcArray[0].lastIndexOf('/') LogUtil.info(TAG, "lastIndex : " + lastIndex) let imgName = "" diff --git a/common/utils/src/main/ets/default/model/databaseModel/SysDefData.ets b/common/utils/src/main/ets/default/model/databaseModel/SysDefData.ets index 92e6d1b7ecf8104e0b7f5d5240bc5da7443d5874..3f9c2fa6a7c45f36e3c775f30ba6abf8b999f6ad 100644 --- a/common/utils/src/main/ets/default/model/databaseModel/SysDefData.ets +++ b/common/utils/src/main/ets/default/model/databaseModel/SysDefData.ets @@ -114,7 +114,7 @@ export default { "title": "数学公式", "uuid": "note1_uuid", "folder_uuid": SysDefFolderUuid.UnClassified, - "content_text": '

好好学习,天天向上



', + "content_text": '

好好学习,天天向上



', "content_img": "/res/shuxue.png", "note_type": NoteType.SysDef, "is_top": Top.Yes, @@ -130,7 +130,7 @@ export default { "title": "UX会议纪要", "uuid": "note2_uuid", "folder_uuid": SysDefFolderUuid.Work, - "content_text": "UX会议纪要", + "content_text": "", "content_img": "", "note_type": NoteType.SysDef, "is_top": Top.Yes, @@ -146,8 +146,8 @@ export default { "title": "旅游心得", "uuid": "note3_uuid", "folder_uuid": SysDefFolderUuid.Work, - "content_text": '

旅游心得



', - "content_img": "/res/lvyou.png", + "content_text": '

要想整个旅程无遗憾,关键是心态。首先要对即将到的目的地有一个正确的认识和恰当的期望。

', + "content_img": "", "note_type": NoteType.SysDef, "is_top": Top.No, "is_favorite": Favorite.No, @@ -162,7 +162,15 @@ export default { "title": "蛋糕做法", "uuid": "note4_uuid", "folder_uuid": SysDefFolderUuid.Life, - "content_text": '

蛋糕做法



', + "content_text": '
' + + '' + + '  糖60g
' + + '' + + '  玉米油40g
' + + '
    1. 添加鸡蛋、盐、糖、蛋糕粉
' + + '    2. 加入玉米油、牛奶,烤箱预热15分钟
' + + '    3. 加入葡萄干、核桃仁,烤箱定时40分钟

' + + '


', "content_img": "/res/cake.png", "note_type": NoteType.CusDef, "is_top": Top.No, diff --git a/common/utils/src/main/ets/default/model/searchModel/SearchModel.ets b/common/utils/src/main/ets/default/model/searchModel/SearchModel.ets index d855f85c6b89d36449149df1c962b6a302bb7d7d..28b886c6e93a775cbff34ab394bc178992e91bb5 100644 --- a/common/utils/src/main/ets/default/model/searchModel/SearchModel.ets +++ b/common/utils/src/main/ets/default/model/searchModel/SearchModel.ets @@ -42,7 +42,7 @@ export class SearchModel { } let searchData: NoteData[] = []; noteDataArray.forEach((noteData) => { - if (decodeURI(noteData.content_text).replace(/<[^>]+>/g,"").toLowerCase().indexOf(query.toLowerCase()) != -1 + if (noteData.content_text.replace(/<[^>]+>/g,"").toLowerCase().indexOf(query.toLowerCase()) != -1 || noteData.title.toLowerCase().indexOf(query.toLowerCase()) != -1) { LogUtil.info(TAG, "uuid " + noteData.uuid) searchData.push(noteData); diff --git a/product/pc/src/main/resources/base/element/color.json b/product/pc/src/main/resources/base/element/color.json index 02771c324f3a1fff11a4b2d89e0e6843427fe282..9576e702632ca8dd7943b8f03fb8f71f7fd53195 100644 --- a/product/pc/src/main/resources/base/element/color.json +++ b/product/pc/src/main/resources/base/element/color.json @@ -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", diff --git a/product/phone/src/main/config.json b/product/phone/src/main/config.json index 0f113fa159ed8cffe807a749de03d424fe65fc4f..5dac9c8e5b6e0ec70fac4a00bf5c3fe9c10d51b2 100644 --- a/product/phone/src/main/config.json +++ b/product/phone/src/main/config.json @@ -59,7 +59,8 @@ }, "pages": [ "pages/MyNoteHome", - "pages/NoteHomePortrait" + "pages/NoteHomePortrait", + "pages/NoteContentHome" ], "name": "MainAbility", "window": { diff --git a/product/phone/src/main/ets/MainAbility/MainAbility.ts b/product/phone/src/main/ets/MainAbility/MainAbility.ts index 7052fc1befcc371e2e193a276fc00e678a0c6141..8062c4f2e6dd95c4932a9847539ed61ebe7a2b7a 100644 --- a/product/phone/src/main/ets/MainAbility/MainAbility.ts +++ b/product/phone/src/main/ets/MainAbility/MainAbility.ts @@ -14,8 +14,8 @@ */ import Ability from '@ohos.application.Ability' -import {WebViewUtil} from './WebViewUtil.ets' import fileio from '@ohos.fileio' +import inputMethod from '@ohos.inputMethod'; export default class MainAbility extends Ability { private Tag = "Phone_Note_MainAbility" @@ -45,6 +45,7 @@ export default class MainAbility extends Ability { if (continueExpand == undefined && continueChoose == undefined) { console.info(this.Tag + " from tablet") AppStorage.SetOrCreate('Choose', true) + AppStorage.SetOrCreate('Expand', false) AppStorage.SetOrCreate('ContinueChoose', true) } @@ -74,14 +75,7 @@ export default class MainAbility extends Ability { onBackground() { console.info(this.Tag + " onBackground") - let controllerShow = WebViewUtil.getWebController() - if (controllerShow == undefined || controllerShow == null) { - console.info("MainAbility onBackground, controllerShow is error") - } - console.info(this.Tag + " controllerShow : " + controllerShow) - controllerShow.runJavaScript({ - script: "get_html_content()" - }) - console.info(this.Tag + " controllerShow end") + // 退出键盘 + inputMethod.getInputMethodController().stopInput(); } } \ No newline at end of file diff --git a/product/phone/src/main/ets/MainAbility/pages/MyNoteHome.ets b/product/phone/src/main/ets/MainAbility/pages/MyNoteHome.ets index ceaaee4b88c2bba09de3b9aa3e8a9ac68db73133..ff7b4ae125debd2ac3c3edc628b7ecb84717e5c9 100644 --- a/product/phone/src/main/ets/MainAbility/pages/MyNoteHome.ets +++ b/product/phone/src/main/ets/MainAbility/pages/MyNoteHome.ets @@ -19,12 +19,14 @@ 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'; @Entry @Component export struct MyNoteHomeComp { @StorageLink('DBQueryFinished') dBQueryFinished: number = 0 @Provide('PortraitModel') portraitModel: boolean = true + @Provide('RefreshFlag') refreshFlag: number = 0 private context = getContext(this) TAG = "MyNoteHomeComp" @@ -98,4 +100,15 @@ export struct MyNoteHomeComp { aboutToDisappear(): void{ LogUtil.info(this.TAG, "aboutToDisappear") } + + onPageShow(): void{ + LogUtil.info(this.TAG, "onPageShow") + this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0) + } + + onBackPress():void{ + LogUtil.info(this.TAG, "onBackPress") + // 退出键盘 + inputMethod.getInputMethodController().stopInput(); + } } \ No newline at end of file diff --git a/product/phone/src/main/ets/MainAbility/WebViewUtil.ets b/product/phone/src/main/ets/MainAbility/pages/NoteContentHome.ets similarity index 38% rename from product/phone/src/main/ets/MainAbility/WebViewUtil.ets rename to product/phone/src/main/ets/MainAbility/pages/NoteContentHome.ets index f1fa1c7b4d29702a1dda1e7bff010340578f4689..aeb1330fa0db3860692c6a8d0bcb68c31c3fcd0a 100644 --- a/product/phone/src/main/ets/MainAbility/WebViewUtil.ets +++ b/product/phone/src/main/ets/MainAbility/pages/NoteContentHome.ets @@ -13,23 +13,30 @@ * limitations under the License. */ -/** - * WebView Util - */ -export class WebViewUtil { - private static controllerShow: WebController - - private constructor() { +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'; - } +@Entry +@Component +struct NoteContentHome { + @Provide('RefreshFlag') refreshFlag: number = 0 + private controllerShow: WebController = new WebController() + TAG = "NoteContentHome" - public static getWebController(): WebController{ - console.info('WebViewUtil, getWebController') - if (!this.controllerShow && AppStorage.Get('openPhoto') == 0 && AppStorage.Get('openPerm') == 0) { - console.info('WebViewUtil, controllerShow is null') - this.controllerShow = new WebController() + build() { + // Note content display area + Flex({ direction: FlexDirection.Column, wrap: FlexWrap.Wrap, justifyContent: FlexAlign.Start }) { + NoteContentCompPortrait({ controllerShow: this.controllerShow }) } - return this.controllerShow + .backgroundColor($r("app.color.notecontent_color_ffffff")) + .width('100%') + .height('100%') } + onBackPress():void{ + LogUtil.info(this.TAG, "onBackPress") + this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setInputEnabled(false)" }) + this.controllerShow.runJavaScript({ script: "get_html_content()" }) + } } \ No newline at end of file diff --git a/product/phone/src/main/ets/MainAbility/pages/NoteHomePortrait.ets b/product/phone/src/main/ets/MainAbility/pages/NoteHomePortrait.ets index 44cd0f61960acb41e30b0e99dfc216183f7388d0..9960800012b389c735989bedbccd789473d8fc18 100644 --- a/product/phone/src/main/ets/MainAbility/pages/NoteHomePortrait.ets +++ b/product/phone/src/main/ets/MainAbility/pages/NoteHomePortrait.ets @@ -28,13 +28,12 @@ import NoteUtil from '../../../../../../../common/utils/src/main/ets/default/bas @Entry @Component export struct NoteHomePortraitComp { - @Provide('RefreshFlag') refreshFlag: number = 0 @StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray') @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表示一分栏 @@ -42,7 +41,7 @@ export struct NoteHomePortraitComp { @Provide('SelectedColor') selectedColor: string = circleColorArray[0]; @Provide('Longpress') longpress: boolean = false // 第二栏长按状态 - // 分栏状态 +// 分栏状态 @Provide('ExpandStatus') expandStatus: boolean = AppStorage.Get('Expand') // 笔记本折叠展开状态 @Provide('ChooseNote') chooseNote: boolean = AppStorage.Get('Choose') // 是否选择笔记进行打开 @@ -73,17 +72,6 @@ export struct NoteHomePortraitComp { .width(StyleConstants.PERCENTAGE_60) .height(StyleConstants.PERCENTAGE_100) .visibility(this.expandStatus == false ? Visibility.None : Visibility.Visible) - - - // Note content display area - if(this.chooseNote == true ) { - Flex({ direction: FlexDirection.Column, wrap: FlexWrap.Wrap, justifyContent: FlexAlign.Start }) { - NoteContentCompPortrait() - } - .backgroundColor($r("app.color.notecontent_color_ffffff")) - .width(StyleConstants.PERCENTAGE_100) - .height(StyleConstants.PERCENTAGE_100) - } } .width(StyleConstants.PERCENTAGE_100).height(StyleConstants.PERCENTAGE_100) } diff --git a/product/phone/src/main/ets/MainAbility/res/lvyou.png b/product/phone/src/main/ets/MainAbility/res/lvyou.png deleted file mode 100644 index 5a4c05f0a9afbf6479b50155db28aaf49ba36e2e..0000000000000000000000000000000000000000 Binary files a/product/phone/src/main/ets/MainAbility/res/lvyou.png and /dev/null differ diff --git a/product/phone/src/main/resources/base/element/color.json b/product/phone/src/main/resources/base/element/color.json index 23674b867de2c4512eae37f886b611eb44eb0e07..76374a33c2ca0c4732ec75705a965876366b4cec 100644 --- a/product/phone/src/main/resources/base/element/color.json +++ b/product/phone/src/main/resources/base/element/color.json @@ -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", diff --git a/product/phone/src/main/resources/rawfile/editor.html b/product/phone/src/main/resources/rawfile/editor.html index 5daf07b96ecc630c06ff6872be2f597b50d10aa6..b1d03d8e25640b86a2784b8586d6860b7067cf42 100644 --- a/product/phone/src/main/resources/rawfile/editor.html +++ b/product/phone/src/main/resources/rawfile/editor.html @@ -4,9 +4,6 @@ "editorJs" - diff --git a/product/phone/src/main/resources/rawfile/editor_style.css b/product/phone/src/main/resources/rawfile/editor_style.css index abf650a03b41d3e337c45387269afacb1db9f6c7..c454d659d2d869dd5499e8bc2a441b16da898640 100644 --- a/product/phone/src/main/resources/rawfile/editor_style.css +++ b/product/phone/src/main/resources/rawfile/editor_style.css @@ -14,9 +14,9 @@ */ html { - height: 15%; + height: 100%; font-family: sans-serif; - -webkit-text-size-adjust: 100%; +-webkit-text-size-adjust: 100%; } body { diff --git a/product/phone/src/main/resources/rawfile/lvyou.png b/product/phone/src/main/resources/rawfile/lvyou.png deleted file mode 100644 index 5a4c05f0a9afbf6479b50155db28aaf49ba36e2e..0000000000000000000000000000000000000000 Binary files a/product/phone/src/main/resources/rawfile/lvyou.png and /dev/null differ diff --git a/product/phone/src/main/resources/rawfile/rich_editor.js b/product/phone/src/main/resources/rawfile/rich_editor.js index c30a8ddf69186fd993eb193849f2cfad34f71349..ee1466913c68bd8571bc042e2edd350e4cf750ad 100644 --- a/product/phone/src/main/resources/rawfile/rich_editor.js +++ b/product/phone/src/main/resources/rawfile/rich_editor.js @@ -18,7 +18,7 @@ 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.editor.innerHTML = contents.replace(/\+/g, '%20'); } RICH_EDITOR.getHtml = function() { @@ -57,7 +57,42 @@ RICH_EDITOR.setUnderline = function() { document.execCommand('underline', false, null); } +RICH_EDITOR.getListStyle = function () { + 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") { + console.info('insertOrderedList') + document.execCommand('insertOrderedList', false, null); + return child.style["list-style"] + } + if (child.nodeName == "UL") { + console.info('insertUnorderedList') + document.execCommand('insertUnorderedList', false, null); + return child.style["list-style"] + } + if (child.parentNode) { + child = child.parentNode + } + } + } catch (err) { + + } + } + +} + RICH_EDITOR.setNumbers = function () { + let listStyle = RICH_EDITOR.getListStyle() + if(listStyle == "decimal") { + return + } document.execCommand('insertOrderedList', false, null); var selection, type; if (window.getSelection) { @@ -83,6 +118,10 @@ RICH_EDITOR.setNumbers = function () { } RICH_EDITOR.setABC = function () { + let listStyle = RICH_EDITOR.getListStyle() + if(listStyle == "lower-alpha") { + return + } document.execCommand('insertOrderedList', false, null); var selection, type; if (window.getSelection) { @@ -108,6 +147,10 @@ RICH_EDITOR.setABC = function () { } RICH_EDITOR.setBullets = function () { + let listStyle = RICH_EDITOR.getListStyle() + if(listStyle == "disc") { + return + } document.execCommand('insertUnorderedList', false, null); var selection, type; if (window.getSelection) { @@ -133,6 +176,10 @@ RICH_EDITOR.setBullets = function () { } RICH_EDITOR.setSquare = function () { + let listStyle = RICH_EDITOR.getListStyle() + if(listStyle == "square") { + return + } document.execCommand('insertUnorderedList', false, null); var selection, type; if (window.getSelection) { @@ -263,21 +310,21 @@ RICH_EDITOR.getSelectedAnchorNode=function(){ function get_html_content() { console.log('get_html_content'); - var htmlString = encodeURI(RICH_EDITOR.getHtml()) + var htmlString = RICH_EDITOR.getHtml() var str = callBackToApp.callbackhtml(htmlString) console.log('get_html_content end'); } function save_html_content() { console.log('save_html_content'); - var htmlString = encodeURI(RICH_EDITOR.getHtml()) + var htmlString = RICH_EDITOR.getHtml() var str = callBackToApp.callbackhtmlSave(htmlString) console.log('save_html_content end'); } function scheduled_save_content() { console.info('scheduled_save_content') - var htmlString = encodeURI(RICH_EDITOR.getHtml()) + var htmlString = RICH_EDITOR.getHtml() var str = callBackToApp.callbackScheduledSave(htmlString) console.info('scheduled_save_content end') } \ No newline at end of file diff --git a/product/tablet/src/main/config.json b/product/tablet/src/main/config.json index bc6af9fac9e9a63fe44f30a481e705966dee4c1a..bd5f01225dec3242bc6f834d690245d07462a9d6 100644 --- a/product/tablet/src/main/config.json +++ b/product/tablet/src/main/config.json @@ -59,7 +59,8 @@ }, "pages": [ "pages/MyNoteHome", - "pages/NoteHome" + "pages/NoteHome", + "pages/NoteContentHome" ], "name": "MainAbility", "window": { diff --git a/product/tablet/src/main/ets/MainAbility/MainAbility.ts b/product/tablet/src/main/ets/MainAbility/MainAbility.ts index c39b761208fee1d01880d6e120399de86422ae09..514d7e4868f0be4ca1ae20870c9ea5b35780db69 100644 --- a/product/tablet/src/main/ets/MainAbility/MainAbility.ts +++ b/product/tablet/src/main/ets/MainAbility/MainAbility.ts @@ -14,8 +14,8 @@ */ import Ability from '@ohos.application.Ability' -import {WebViewUtil} from './WebViewUtil.ets' import fileio from '@ohos.fileio' +import inputMethod from '@ohos.inputMethod'; export default class MainAbility extends Ability { private Tag = "Tablet_Note_MainAbility" @@ -62,14 +62,7 @@ export default class MainAbility extends Ability { onBackground() { console.info(this.Tag + " onBackground") - let controllerShow = WebViewUtil.getWebController() - if (controllerShow == undefined || controllerShow == null) { - console.info("MainAbility onBackground, controllerShow is error") - } - console.info(this.Tag + " controllerShow : " + controllerShow) - controllerShow.runJavaScript({ - script: "get_html_content()" - }) - console.info(this.Tag + " controllerShow end") + // 退出键盘 + inputMethod.getInputMethodController().stopInput(); } } \ No newline at end of file diff --git a/product/tablet/src/main/ets/MainAbility/WebViewUtil.ets b/product/tablet/src/main/ets/MainAbility/WebViewUtil.ets deleted file mode 100644 index f1fa1c7b4d29702a1dda1e7bff010340578f4689..0000000000000000000000000000000000000000 --- a/product/tablet/src/main/ets/MainAbility/WebViewUtil.ets +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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 && AppStorage.Get('openPhoto') == 0 && AppStorage.Get('openPerm') == 0) { - console.info('WebViewUtil, controllerShow is null') - this.controllerShow = new WebController() - } - return this.controllerShow - } - -} \ No newline at end of file diff --git a/product/tablet/src/main/ets/MainAbility/pages/MyNoteHome.ets b/product/tablet/src/main/ets/MainAbility/pages/MyNoteHome.ets index 6814328031cc98d8fbf4820d90682654b8418636..149ef2bbf9e3771fecd8ff81e300f735beb2dda6 100644 --- a/product/tablet/src/main/ets/MainAbility/pages/MyNoteHome.ets +++ b/product/tablet/src/main/ets/MainAbility/pages/MyNoteHome.ets @@ -19,19 +19,23 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl' import {NoteHomeComp} from './NoteHome.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 NoteData from '../../../../../../../common/utils/src/main/ets/default/model/databaseModel/NoteData.ets' +import inputMethod from '@ohos.inputMethod'; @Entry @Component export struct MyNoteHomeComp { @StorageLink('DBQueryFinished') dBQueryFinished: number = 0 @Provide('PortraitModel') portraitModel: boolean = false + @Provide('RefreshFlag') refreshFlag: number = 0 + private controllerShow: WebController = new WebController() private context = getContext(this) TAG = "MyNoteHomeComp" build() { Row() { if (this.dBQueryFinished == 1) { - NoteHomeComp() + NoteHomeComp({ controllerShow: this.controllerShow }) } } .width('100%') @@ -99,4 +103,19 @@ export struct MyNoteHomeComp { aboutToDisappear(): void{ LogUtil.info(this.TAG, "aboutToDisappear") } + + onPageShow(): void{ + LogUtil.info(this.TAG, "onPageShow") + let currentNote = AppStorage.Get('NewNote') + if (currentNote != null) { + this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setHtml('" + currentNote.content_text + "')" }) + } + this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0) + } + + onBackPress():void{ + LogUtil.info(this.TAG, "onBackPress") + // 退出键盘 + inputMethod.getInputMethodController().stopInput(); + } } \ No newline at end of file diff --git a/common/utils/src/main/ets/default/baseUtil/WebViewUtil.ets b/product/tablet/src/main/ets/MainAbility/pages/NoteContentHome.ets similarity index 40% rename from common/utils/src/main/ets/default/baseUtil/WebViewUtil.ets rename to product/tablet/src/main/ets/MainAbility/pages/NoteContentHome.ets index 4443def7d3ae1133c9b4d38fdb2ecabed574a2d9..fcbffb594a4efc25dd02c572ff7e10808bbd8e19 100644 --- a/common/utils/src/main/ets/default/baseUtil/WebViewUtil.ets +++ b/product/tablet/src/main/ets/MainAbility/pages/NoteContentHome.ets @@ -13,23 +13,29 @@ * limitations under the License. */ -/** - * WebView Util - */ -export class WebViewUtil { - private static controllerShow: WebController - - private constructor() { +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'; - } +@Entry +@Component +struct NoteContentHome { + private controllerShow: WebController = new WebController() + TAG = "NoteContentHome" - public static getWebController(): WebController{ - console.info('WebViewUtil, getWebController') - if (!this.controllerShow) { - console.info('WebViewUtil, controllerShow is null') - this.controllerShow = new WebController() + build() { + // Note content display area + Flex({ direction: FlexDirection.Column, wrap: FlexWrap.Wrap, justifyContent: FlexAlign.Start }) { + NoteContent({ controllerShow: this.controllerShow }) } - return this.controllerShow + .backgroundColor($r("app.color.notecontent_color_ffffff")) + .width('100%') + .height('100%') } + onBackPress():void{ + LogUtil.info(this.TAG, "onBackPress") + this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setInputEnabled(false)" }) + this.controllerShow.runJavaScript({ script: "get_html_content()" }) + } } \ No newline at end of file diff --git a/product/tablet/src/main/ets/MainAbility/pages/NoteHome.ets b/product/tablet/src/main/ets/MainAbility/pages/NoteHome.ets index 7c45829657159048f4e7796cc8c3a986b29bf65f..84d9e6d5c6421ff7f85ffe6f98c07b85d8354f4a 100644 --- a/product/tablet/src/main/ets/MainAbility/pages/NoteHome.ets +++ b/product/tablet/src/main/ets/MainAbility/pages/NoteHome.ets @@ -24,18 +24,16 @@ 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' import mediaquery from '@ohos.mediaquery' @Entry @Component export struct NoteHomeComp { - @Provide('RefreshFlag') refreshFlag: number = 0 @StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray') @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') @@ -49,7 +47,8 @@ export struct NoteHomeComp { @Provide('InputKeyword') inputKeyword: string = '' // 搜索的字串 @Provide('SelectedAll') selectedAll: boolean = false @Provide('EditModel') editModel: boolean = false //编辑模式:临时方案 - private controllerShow: WebController = WebViewUtil.getWebController() //第三栏展示 + @Provide('Issave') issave: number = 0 + controllerShow: WebController TAG = "NoteHomeComp" diff --git a/product/tablet/src/main/ets/MainAbility/res/lvyou.png b/product/tablet/src/main/ets/MainAbility/res/lvyou.png deleted file mode 100644 index 5a4c05f0a9afbf6479b50155db28aaf49ba36e2e..0000000000000000000000000000000000000000 Binary files a/product/tablet/src/main/ets/MainAbility/res/lvyou.png and /dev/null differ diff --git a/product/tablet/src/main/resources/base/element/color.json b/product/tablet/src/main/resources/base/element/color.json index 23674b867de2c4512eae37f886b611eb44eb0e07..76374a33c2ca0c4732ec75705a965876366b4cec 100644 --- a/product/tablet/src/main/resources/base/element/color.json +++ b/product/tablet/src/main/resources/base/element/color.json @@ -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", diff --git a/product/tablet/src/main/resources/base/media/foldMove_select.svg b/product/tablet/src/main/resources/base/media/foldMove_select.svg index 6b7b9d104f70c7c42cf1b55968c2741c7bb8d2b6..f02ccc3ed44986345a9d006602791f667b0b9226 100644 --- a/product/tablet/src/main/resources/base/media/foldMove_select.svg +++ b/product/tablet/src/main/resources/base/media/foldMove_select.svg @@ -3,10 +3,10 @@ diff --git a/product/tablet/src/main/resources/base/media/tick_thick.svg b/product/tablet/src/main/resources/base/media/tick_thick.svg index ca03aeffca1cffce401404f626ca0d9250aec3a3..7db3a2014c767a11f2e20fbe2bdd11b17528b756 100644 --- a/product/tablet/src/main/resources/base/media/tick_thick.svg +++ b/product/tablet/src/main/resources/base/media/tick_thick.svg @@ -1 +1 @@ -勾 粗 \ No newline at end of file +勾 粗 \ No newline at end of file diff --git a/product/tablet/src/main/resources/rawfile/editor.html b/product/tablet/src/main/resources/rawfile/editor.html index 5daf07b96ecc630c06ff6872be2f597b50d10aa6..b1d03d8e25640b86a2784b8586d6860b7067cf42 100644 --- a/product/tablet/src/main/resources/rawfile/editor.html +++ b/product/tablet/src/main/resources/rawfile/editor.html @@ -4,9 +4,6 @@ "editorJs" - diff --git a/product/tablet/src/main/resources/rawfile/editor_style.css b/product/tablet/src/main/resources/rawfile/editor_style.css index abf650a03b41d3e337c45387269afacb1db9f6c7..2460c25e49b340c07ed4fd5153cdbfc00472ea68 100644 --- a/product/tablet/src/main/resources/rawfile/editor_style.css +++ b/product/tablet/src/main/resources/rawfile/editor_style.css @@ -14,7 +14,7 @@ */ html { - height: 15%; + height: 100%; font-family: sans-serif; -webkit-text-size-adjust: 100%; } diff --git a/product/tablet/src/main/resources/rawfile/lvyou.png b/product/tablet/src/main/resources/rawfile/lvyou.png deleted file mode 100644 index 5a4c05f0a9afbf6479b50155db28aaf49ba36e2e..0000000000000000000000000000000000000000 Binary files a/product/tablet/src/main/resources/rawfile/lvyou.png and /dev/null differ diff --git a/product/tablet/src/main/resources/rawfile/rich_editor.js b/product/tablet/src/main/resources/rawfile/rich_editor.js index c30a8ddf69186fd993eb193849f2cfad34f71349..ee1466913c68bd8571bc042e2edd350e4cf750ad 100644 --- a/product/tablet/src/main/resources/rawfile/rich_editor.js +++ b/product/tablet/src/main/resources/rawfile/rich_editor.js @@ -18,7 +18,7 @@ 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.editor.innerHTML = contents.replace(/\+/g, '%20'); } RICH_EDITOR.getHtml = function() { @@ -57,7 +57,42 @@ RICH_EDITOR.setUnderline = function() { document.execCommand('underline', false, null); } +RICH_EDITOR.getListStyle = function () { + 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") { + console.info('insertOrderedList') + document.execCommand('insertOrderedList', false, null); + return child.style["list-style"] + } + if (child.nodeName == "UL") { + console.info('insertUnorderedList') + document.execCommand('insertUnorderedList', false, null); + return child.style["list-style"] + } + if (child.parentNode) { + child = child.parentNode + } + } + } catch (err) { + + } + } + +} + RICH_EDITOR.setNumbers = function () { + let listStyle = RICH_EDITOR.getListStyle() + if(listStyle == "decimal") { + return + } document.execCommand('insertOrderedList', false, null); var selection, type; if (window.getSelection) { @@ -83,6 +118,10 @@ RICH_EDITOR.setNumbers = function () { } RICH_EDITOR.setABC = function () { + let listStyle = RICH_EDITOR.getListStyle() + if(listStyle == "lower-alpha") { + return + } document.execCommand('insertOrderedList', false, null); var selection, type; if (window.getSelection) { @@ -108,6 +147,10 @@ RICH_EDITOR.setABC = function () { } RICH_EDITOR.setBullets = function () { + let listStyle = RICH_EDITOR.getListStyle() + if(listStyle == "disc") { + return + } document.execCommand('insertUnorderedList', false, null); var selection, type; if (window.getSelection) { @@ -133,6 +176,10 @@ RICH_EDITOR.setBullets = function () { } RICH_EDITOR.setSquare = function () { + let listStyle = RICH_EDITOR.getListStyle() + if(listStyle == "square") { + return + } document.execCommand('insertUnorderedList', false, null); var selection, type; if (window.getSelection) { @@ -263,21 +310,21 @@ RICH_EDITOR.getSelectedAnchorNode=function(){ function get_html_content() { console.log('get_html_content'); - var htmlString = encodeURI(RICH_EDITOR.getHtml()) + var htmlString = RICH_EDITOR.getHtml() var str = callBackToApp.callbackhtml(htmlString) console.log('get_html_content end'); } function save_html_content() { console.log('save_html_content'); - var htmlString = encodeURI(RICH_EDITOR.getHtml()) + var htmlString = RICH_EDITOR.getHtml() var str = callBackToApp.callbackhtmlSave(htmlString) console.log('save_html_content end'); } function scheduled_save_content() { console.info('scheduled_save_content') - var htmlString = encodeURI(RICH_EDITOR.getHtml()) + var htmlString = RICH_EDITOR.getHtml() var str = callBackToApp.callbackScheduledSave(htmlString) console.info('scheduled_save_content end') } \ No newline at end of file