mirror of
https://gitee.com/openharmony/applications_notes
synced 2024-11-27 09:40:36 +00:00
commit
2f896b8daa
@ -69,6 +69,7 @@ export struct NewOrEditFolderDialog {
|
||||
this.isExisted = result
|
||||
})
|
||||
})
|
||||
.restoreId(1)
|
||||
}.margin({ bottom: 4, left: 24, right: 24 })
|
||||
|
||||
Divider()
|
||||
@ -682,6 +683,7 @@ export struct EditTitleDialog {
|
||||
}
|
||||
this.inputName = value
|
||||
})
|
||||
.restoreId(2)
|
||||
}.margin({ bottom: 4, left: 24, right: 24 })
|
||||
|
||||
|
||||
|
@ -46,6 +46,37 @@ export struct NoteContent {
|
||||
@Provide('EditModel') editModel: boolean = false
|
||||
controllerShow: WebController
|
||||
private editContentFlag = false
|
||||
@StorageLink('ScrollTopPercent') scrollTopPercent: number = 0.0
|
||||
storeScrollTop(scrollTop: number) {
|
||||
if (scrollTop < 0) {
|
||||
return
|
||||
}
|
||||
AppStorage.SetOrCreate<number>('ScrollTopPercent', scrollTop/this.controllerShow.getPageHeight())
|
||||
}
|
||||
restoreScrollTop() {
|
||||
if (!AppStorage.Has('remoteScrollTopPercent')) {
|
||||
return
|
||||
}
|
||||
var scrollTopPercent = AppStorage.Get<number>('remoteScrollTopPercent')
|
||||
if (scrollTopPercent < 0) {
|
||||
return
|
||||
}
|
||||
this.controllerShow.runJavaScript({
|
||||
script: 'document.documentElement.scrollTop = ' + this.controllerShow.getPageHeight()*scrollTopPercent
|
||||
})
|
||||
AppStorage.Delete('remoteScrollTopPercent')
|
||||
}
|
||||
restoreFocus() {
|
||||
if (!AppStorage.Has('isRemoteFocusOnSearch')) {
|
||||
return
|
||||
}
|
||||
let isRemoteFocusOnSearch = AppStorage.Get<boolean>('isRemoteFocusOnSearch')
|
||||
if (isRemoteFocusOnSearch) {
|
||||
focusControl.requestFocus('searchInput')
|
||||
}
|
||||
AppStorage.Delete('isRemoteFocusOnSearch')
|
||||
}
|
||||
|
||||
noteContent = {
|
||||
callbackhtml: (html) => {
|
||||
LogUtil.info(TAG, 'note uuid is:' + this.selectedNoteData.uuid)
|
||||
@ -136,8 +167,16 @@ export struct NoteContent {
|
||||
.onPageEnd((e) => {
|
||||
LogUtil.info(TAG, "finish loadurl")
|
||||
if (this.selectedNoteData) {
|
||||
let self = this
|
||||
this.controllerShow.runJavaScript({
|
||||
script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')"
|
||||
script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')",
|
||||
callback: () => {
|
||||
// wait for the image in the note to load
|
||||
setTimeout(function() {
|
||||
self.restoreScrollTop()
|
||||
self.restoreFocus()
|
||||
}, 100)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
@ -148,6 +187,9 @@ export struct NoteContent {
|
||||
.domStorageAccess(true)
|
||||
.height('70%')
|
||||
.width('100%')
|
||||
.onScroll((event) => {
|
||||
this.storeScrollTop(event.yOffset)
|
||||
})
|
||||
}
|
||||
.margin({ left: 12, right: 24, top: 16 })
|
||||
.width(StyleConstants.PERCENTAGE_100)
|
||||
|
@ -54,6 +54,36 @@ export struct NoteContentComp {
|
||||
private editContentFlag = false
|
||||
@State uri1: string = ""
|
||||
private context = getContext(this)
|
||||
@StorageLink('ScrollTopPercent') scrollTopPercent: number = 0.0
|
||||
storeScrollTop(scrollTop: number) {
|
||||
if (scrollTop < 0) {
|
||||
return
|
||||
}
|
||||
AppStorage.SetOrCreate<number>('ScrollTopPercent', scrollTop/this.controllerShow.getPageHeight())
|
||||
}
|
||||
restoreScrollTop() {
|
||||
if (!AppStorage.Has('remoteScrollTopPercent')) {
|
||||
return
|
||||
}
|
||||
var scrollTopPercent = AppStorage.Get<number>('remoteScrollTopPercent')
|
||||
if (scrollTopPercent < 0) {
|
||||
return
|
||||
}
|
||||
this.controllerShow.runJavaScript({
|
||||
script: 'document.documentElement.scrollTop = ' + this.controllerShow.getPageHeight()*scrollTopPercent
|
||||
})
|
||||
}
|
||||
restoreFocus() {
|
||||
if (!AppStorage.Has('isRemoteFocusOnSearch')) {
|
||||
return
|
||||
}
|
||||
let isRemoteFocusOnSearch = AppStorage.Get<boolean>('isRemoteFocusOnSearch')
|
||||
if (isRemoteFocusOnSearch) {
|
||||
focusControl.requestFocus('searchInput')
|
||||
}
|
||||
AppStorage.Delete('isRemoteFocusOnSearch')
|
||||
}
|
||||
|
||||
noteContent = {
|
||||
callbackhtml: (html) => {
|
||||
LogUtil.info(TAG, 'note uuid is:' + this.selectedNoteData.uuid)
|
||||
@ -171,8 +201,16 @@ export struct NoteContentComp {
|
||||
.onPageEnd((e) => {
|
||||
LogUtil.info(TAG, "finish loadurl")
|
||||
if(this.selectedNoteData){
|
||||
let self = this
|
||||
this.controllerShow.runJavaScript({
|
||||
script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')"
|
||||
script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')",
|
||||
callback: () => {
|
||||
// wait for the image in the note to load
|
||||
setTimeout(function() {
|
||||
self.restoreScrollTop()
|
||||
self.restoreFocus()
|
||||
}, 100)
|
||||
}
|
||||
})
|
||||
}
|
||||
// 初次加载为为小屏预览模式
|
||||
@ -187,6 +225,9 @@ export struct NoteContentComp {
|
||||
.zoomAccess(false)
|
||||
.height('88%')
|
||||
.width('100%')
|
||||
.onScroll((event) => {
|
||||
this.storeScrollTop(event.yOffset)
|
||||
})
|
||||
}
|
||||
.margin({ left: 24, right: 24 })
|
||||
// .width(StyleConstants.PERCENTAGE_100)
|
||||
|
@ -54,6 +54,36 @@ export struct NoteContentCompPortrait {
|
||||
@StorageLink('closeEditContentDialog') closeEditContentDialog: boolean = AppStorage.Link('closeEditContentDialog')
|
||||
controllerShow: WebController
|
||||
private editContentFlag = false
|
||||
@StorageLink('ScrollTopPercent') scrollTopPercent: number = 0.0
|
||||
storeScrollTop(scrollTop: number) {
|
||||
if (scrollTop < 0) {
|
||||
return
|
||||
}
|
||||
AppStorage.SetOrCreate<number>('ScrollTopPercent', scrollTop/this.controllerShow.getPageHeight())
|
||||
}
|
||||
restoreScrollTop() {
|
||||
if (!AppStorage.Has('remoteScrollTopPercent')) {
|
||||
return
|
||||
}
|
||||
var scrollTopPercent = AppStorage.Get<number>('remoteScrollTopPercent')
|
||||
if (scrollTopPercent < 0) {
|
||||
return
|
||||
}
|
||||
this.controllerShow.runJavaScript({
|
||||
script: 'document.documentElement.scrollTop = ' + this.controllerShow.getPageHeight()*scrollTopPercent
|
||||
})
|
||||
}
|
||||
restoreFocus() {
|
||||
if (!AppStorage.Has('isRemoteFocusOnSearch')) {
|
||||
return
|
||||
}
|
||||
let isRemoteFocusOnSearch = AppStorage.Get<boolean>('isRemoteFocusOnSearch')
|
||||
if (isRemoteFocusOnSearch) {
|
||||
focusControl.requestFocus('searchInput')
|
||||
}
|
||||
AppStorage.Delete('isRemoteFocusOnSearch')
|
||||
}
|
||||
|
||||
noteContent = {
|
||||
callbackhtml: (html) => {
|
||||
LogUtil.info(TAG, 'note uuid is:' + this.selectedNoteData.uuid)
|
||||
@ -139,8 +169,16 @@ export struct NoteContentCompPortrait {
|
||||
})
|
||||
.onPageEnd((e) => {
|
||||
LogUtil.info(TAG, "finish loadurl")
|
||||
let self = this
|
||||
this.controllerShow.runJavaScript({
|
||||
script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')"
|
||||
script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')",
|
||||
callback: () => {
|
||||
// wait for the image in the note to load
|
||||
setTimeout(function() {
|
||||
self.restoreScrollTop()
|
||||
self.restoreFocus()
|
||||
}, 100)
|
||||
}
|
||||
})
|
||||
})
|
||||
.imageAccess(true)
|
||||
@ -150,6 +188,9 @@ export struct NoteContentCompPortrait {
|
||||
.zoomAccess(false)
|
||||
.height('100%')
|
||||
.width('100%')
|
||||
.onScroll((event) => {
|
||||
this.storeScrollTop(event.yOffset)
|
||||
})
|
||||
}
|
||||
.flexShrink(1)
|
||||
.onClick(() => {
|
||||
|
@ -670,6 +670,7 @@ export struct SearchComp {
|
||||
@Consume('InputKeyword') inputKeyword: string
|
||||
@Consume('Longpress') longpress: boolean
|
||||
@State text: string = ''
|
||||
@StorageLink('isFocusOnSearch') isFocusOnSearch: boolean = true
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
@ -708,6 +709,16 @@ export struct SearchComp {
|
||||
this.search = true
|
||||
}
|
||||
})
|
||||
// whether the focus is on the search input before coutinue
|
||||
.onFocus(() => {
|
||||
this.isFocusOnSearch = true
|
||||
})
|
||||
.onBlur(() => {
|
||||
this.isFocusOnSearch = false
|
||||
})
|
||||
// key for request focus after coutinue
|
||||
.key('searchInput')
|
||||
.restoreId(3)
|
||||
}
|
||||
.backgroundColor(this.longpress ? $r("app.color.search_longpress_bgcolor_f7f8f9") : $r("app.color.color_ffffff"))
|
||||
.height(40)
|
||||
|
@ -52,6 +52,7 @@
|
||||
"icon": "$media:note",
|
||||
"label": "$string:entry_MainAbility",
|
||||
"visible": true,
|
||||
"continuable": true,
|
||||
"skills": [
|
||||
{
|
||||
"entities": [
|
||||
|
@ -38,9 +38,14 @@ export default class MainAbility extends Ability {
|
||||
// 获取对端的迁移数据
|
||||
let continueNote: string = want.parameters["ContinueNote"]
|
||||
let continueSection: number = want.parameters["ContinueSection"]
|
||||
let scrollTopPercent: number = want.parameters["ScrollTopPercent"]
|
||||
let isFocusOnSearch: boolean = want.parameters["isFocusOnSearch"]
|
||||
LogUtil.info(this.Tag, " continueSection : " + continueSection)
|
||||
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
|
||||
AppStorage.SetOrCreate<number>('ContinueSection', continueSection)
|
||||
// 使用新的key保存数据,防止迁移过来的数据在使用前被本地操作覆盖
|
||||
AppStorage.SetOrCreate<number>('remoteScrollTopPercent', scrollTopPercent)
|
||||
AppStorage.SetOrCreate<boolean>('isRemoteFocusOnSearch', isFocusOnSearch)
|
||||
// 来自手机的迁移
|
||||
let continueChoose: boolean = want.parameters["ContinueChoose"]
|
||||
if (continueChoose) {
|
||||
@ -94,9 +99,23 @@ export default class MainAbility extends Ability {
|
||||
}
|
||||
LogUtil.info(this.Tag, " onContinue, continueSection : " + continueSection)
|
||||
|
||||
let scrollTopPercent = AppStorage.Get<number>('ScrollTopPercent')
|
||||
if (scrollTopPercent == undefined || scrollTopPercent == null) {
|
||||
LogUtil.info(this.Tag, " onContinue, scrollTopPercent is error, default 0")
|
||||
scrollTopPercent = 0
|
||||
}
|
||||
|
||||
let isFocusOnSearch = AppStorage.Get<boolean>('isFocusOnSearch')
|
||||
if (isFocusOnSearch == undefined || isFocusOnSearch == null) {
|
||||
LogUtil.info(this.Tag, " onContinue, isFocusOnSearch is error, default true")
|
||||
isFocusOnSearch = true
|
||||
}
|
||||
|
||||
// 保存本端的迁移数据
|
||||
wantParam["ContinueNote"] = continueNote
|
||||
wantParam["ContinueSection"] = continueSection
|
||||
wantParam["ScrollTopPercent"] = scrollTopPercent
|
||||
wantParam["isFocusOnSearch"] = isFocusOnSearch
|
||||
if (deviceInfo.deviceType === 'phone' || deviceInfo.deviceType === 'default') {
|
||||
wantParam["ContinueChoose"] = true
|
||||
}
|
||||
|
@ -57,6 +57,7 @@
|
||||
"icon": "$media:note",
|
||||
"label": "$string:entry_MainAbility",
|
||||
"visible": true,
|
||||
"continuable": true,
|
||||
"skills": [
|
||||
{
|
||||
"entities": [
|
||||
|
Loading…
Reference in New Issue
Block a user