!147 修复按钮会被键盘遮盖问题

Merge pull request !147 from 黎思泉/master
This commit is contained in:
openharmony_ci
2022-12-12 03:56:33 +00:00
committed by Gitee
7 changed files with 309 additions and 309 deletions
@@ -13,12 +13,29 @@
href="editor_style.css">
</head>
<body onload="load()">
<div
id="editorjs"
contenteditable="true">
<div class="edit-box">
<div
id="editorjs"
contenteditable="true">
</div>
<div class="button-box">
<div id="addToDo">
<img id="img1" src="../base/media/todo1.svg">
<span id="lable1">清单</span>
</div>
<div id="chooseStyle">
<img id="img2" src="../base/media/styles.svg">
<span id="lable2">样式</span>
</div>
<div id="openAlbum">
<img id="img3"src="../base/media/picture_white.svg">
<span id="lable3">相册</span>
</div>
</div>
</div>
<script
type="text/javascript"
src="rich_editor.js"></script>
</body>
</html>
</html>
@@ -16,24 +16,21 @@
html {
height: 100%;
font-family: sans-serif;
-webkit-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
}
body {
overflow: scroll;
display: table;
table-layout: fixed;
width: 100%;
min-height: 100%;
height: 100%;
color: #333333;
margin: 0;
height: 100%;
}
#editorjs {
padding-left: 1px;
padding-right: 24px;
width: 100%;
height: 100%;
outline: 0px solid transparent;
background-repeat: no-repeat;
background-position: center;
@@ -41,7 +38,7 @@ body {
color: #182431;
opacity: 0.9;
font-size: 16vp;
height: 100%;
overflow: scroll;
}
#editorjs[placeholder]:empty:not(:focus):before {
@@ -66,9 +63,9 @@ body {
background-color: #ffffff;
border: 2px solid #182431;
opacity: 0.6;
-webkit-border-radius: 50%;
-webkit-appearance: none;
-webkit-user-select: none;
-webkit-border-radius: 50%;
-webkit-appearance: none;
-webkit-user-select: none;
border-radius: 50%;
font-size: 0.8rem;
margin-left: 0px;
@@ -79,7 +76,7 @@ body {
padding: 0;
position: relative;
display: inline-block;
-webkit-transition: background-color ease 0.1s;
-webkit-transition: background-color ease 0.1s;
transition: background-color ease 0.1s;
vertical-align: top;
cursor: default;
@@ -92,3 +89,35 @@ body {
color: #F88805;
opacity: 0.4;
}
.edit-box {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
}
.button-box {
width: 100%;
height: auto;
background-color: white;
display: flex;
justify-content: space-around;
padding-bottom: 6px;
}
.button-box div {
display: flex;
flex-direction: column;
align-items: center;
}
.button-box img {
width: 40px;
height: 40px;
margin-bottom: 6px;
}
.button-box span {
font-size: 16px;
}
@@ -426,4 +426,55 @@ RICH_EDITOR.insertImageHtml = function (contents) {
let img = document.createElement('img');
img.src = contents;
selection.getRangeAt(0).insertNode(img);
};
};
document.getElementById('addToDo').addEventListener('click', () => {
callBackToApp.addToDo()
})
document.getElementById('chooseStyle').addEventListener('click', () => {
callBackToApp.chooseStyle()
})
document.getElementById('openAlbum').addEventListener('click', () => {
callBackToApp.openAlbum()
})
function changeSizeToRk() {
document.getElementById('editorjs').style.fontSize = '24px';
document.getElementById('img1').style.fontSize = '40px';
document.getElementById('img1').style.fontSize = '40px';
document.getElementById('img2').style.fontSize = '40px';
document.getElementById('img2').style.fontSize = '40px';
document.getElementById('img3').style.fontSize = '40px';
document.getElementById('img3').style.fontSize = '40px';
document.getElementById('lable1').style.fontSize = '20px';
document.getElementById('lable2').style.fontSize = '20px';
document.getElementById('lable3').style.fontSize = '20px';
}
function changeSizeToPhone() {
document.getElementById('editorjs').style.fontSize = '16px';
document.getElementById('img1').style.fontSize = '30px';
document.getElementById('img1').style.fontSize = '30px';
document.getElementById('img2').style.fontSize = '30px';
document.getElementById('img2').style.fontSize = '30px';
document.getElementById('img3').style.fontSize = '30px';
document.getElementById('img3').style.fontSize = '30px';
document.getElementById('lable1').style.fontSize = '14px';
document.getElementById('lable2').style.fontSize = '14px';
document.getElementById('lable3').style.fontSize = '14px';
}
function changeSizeToTablet() {
document.getElementById('editorjs').style.fontSize = '16px';
document.getElementById('img1').style.fontSize = '28px';
document.getElementById('img1').style.fontSize = '28px';
document.getElementById('img2').style.fontSize = '28px';
document.getElementById('img2').style.fontSize = '28px';
document.getElementById('img3').style.fontSize = '28px';
document.getElementById('img3').style.fontSize = '28px';
document.getElementById('lable1').style.fontSize = '12px';
document.getElementById('lable2').style.fontSize = '12px';
document.getElementById('lable3').style.fontSize = '12px';
}
@@ -48,9 +48,20 @@ export struct NoteContent {
@StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray')
@Provide('Issave') issave: number = 0
@Provide('EditModel') editModel: boolean = false
@StorageLink('dpi') dpi: number = 240
controllerShow: WebController
private editContentFlag = false
@StorageLink('ScrollTopPercent') scrollTopPercent: number = 0.0
editContentDialogCtl: CustomDialogController = new CustomDialogController({
builder: EditContentDialog({ confirm: this.confirm.bind(this) }),
alignment: DialogAlignment.Bottom,
autoCancel: true,
customStyle: true,
})
confirm(excuteJs: string) {
this.controllerShow.runJavaScript({ script: excuteJs })
}
storeScrollTop(scrollTop: number) {
if (scrollTop < 0) {
@@ -166,6 +177,55 @@ export struct NoteContent {
} else if (fontSize === 48) {
this.selectedNoteData.slider_value = 16
}
},
addToDo: () => {
// 退出键盘
// @ts-ignore
inputMethod.getController().stopInputSession();
// 清单
this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.setTodo()" })
},
chooseStyle: () => {
// 退出键盘
// @ts-ignore
inputMethod.getController().stopInputSession();
LogUtil.info(TAG, 'editContentDialogCtl start')
this.editContentDialogCtl.open()
},
openAlbum: async () => {
// 退出键盘
// @ts-ignore
inputMethod.getController().stopInputSession();
LogUtil.info(TAG, 'startAbility start')
await globalThis.noteContext.startAbilityForResult({
parameters: { uri: "singleselect" },
bundleName: "com.ohos.photos",
abilityName: "com.ohos.photos.MainAbility",
})
.then(v => {
let want = v['want'];
if (want != null && want != undefined) {
let param = want['parameters'];
let imageUri = ""
if (param != null && param != undefined) {
let uri = param['select-item-list'];
imageUri = uri;
}
// 拷贝
if (imageUri != null && imageUri != "") {
OperationUtils.copy(imageUri).then((uriPath) => {
var path = "file://" + uriPath
LogUtil.info(TAG, 'image uri is:' + path)
this.controllerShow.runJavaScript({
script: "javascript:RICH_EDITOR.insertImage('" + path + "')"
})
this.issave = 1
// 保存笔记信息到数据库
this.controllerShow.runJavaScript({ script: "getHtmlContent()" })
})
}
}
});
}
}
@@ -185,10 +245,17 @@ export struct NoteContent {
.javaScriptProxy({
object: this.noteContent,
name: "callBackToApp", // html--> name.method
methodList: ["callbackhtml", "callbackScheduledSave", "callbackPasteImage", "callbackImagePath", "callbackGetSize"],
methodList: ["callbackhtml", "callbackScheduledSave", "callbackPasteImage", "callbackImagePath", "callbackGetSize", "addToDo", "chooseStyle", "openAlbum"],
controller: this.controllerShow
})
.onPageEnd((e) => {
if (this.dpi <= 240) {
this.controllerShow.runJavaScript({ script: "changeSizeToRk()" })
} else if (this.dpi >= 320 && this.dpi > 240) {
this.controllerShow.runJavaScript({ script: "changeSizeToPhone()" })
} else {
this.controllerShow.runJavaScript({ script: "changeSizeToTablet()" })
}
LogUtil.info(TAG, "finish loadurl")
if (this.selectedNoteData) {
let self = this
@@ -220,7 +287,7 @@ export struct NoteContent {
clearInterval(timeID)
}
timeID = setInterval(() => {
this.controllerShow.runJavaScript({ script: "scheduledSaveContent()" })
this.controllerShow.runJavaScript({ script: "scheduledSaveContent()" })
}, 3000)
LogUtil.info(TAG, "setInterval timeID : " + timeID)
this.issave = 0
@@ -253,16 +320,6 @@ export struct ToolBarComp {
@Consume('Issave') issave: number
@Consume('EditModel') editModel: boolean
controllerShow: WebController
editContentDialogCtl: CustomDialogController = new CustomDialogController({
builder: EditContentDialog({ confirm: this.confirm.bind(this) }),
alignment: DialogAlignment.Bottom,
autoCancel: true,
customStyle: true,
})
confirm(excuteJs: string) {
this.controllerShow.runJavaScript({ script: excuteJs })
}
build() {
Flex({ direction: FlexDirection.Row, wrap: FlexWrap.NoWrap,
@@ -303,81 +360,6 @@ export struct ToolBarComp {
.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(() => {
// 退出键盘
// @ts-ignore
inputMethod.getController().stopInputSession();
// 清单
this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.setTodo()" })
})
}.width(42)
.height(42)
.borderRadius(8)
.backgroundColor($r('app.color.color_fffffB'))
Button({ type: ButtonType.Normal, stateEffect: true }) {
Image($r('app.media.font_style'))
.height(24)
.width(24)
.onClick(() => {
// 退出键盘
// @ts-ignore
inputMethod.getController().stopInputSession();
LogUtil.info(TAG, 'editContentDialogCtl start')
this.editContentDialogCtl.open()
})
}.width(42)
.height(42)
.borderRadius(8)
.backgroundColor($r('app.color.color_fffffB'))
Button({ type: ButtonType.Normal, stateEffect: true }) {
Image($r('app.media.picture_white')).height(24).width(24)
.onClick(async () => {
// 退出键盘
// @ts-ignore
inputMethod.getController().stopInputSession();
LogUtil.info(TAG, 'startAbility start')
await globalThis.noteContext.startAbilityForResult({
parameters: { uri: "singleselect" },
bundleName: "com.ohos.photos",
abilityName: "com.ohos.photos.MainAbility",
})
.then(v => {
let want = v['want'];
if (want != null && want != undefined) {
let param = want['parameters'];
let imageUri = ""
if (param != null && param != undefined) {
let uri = param['select-item-list'];
imageUri = uri;
}
// 拷贝
if (imageUri != null && imageUri != "") {
OperationUtils.copy(imageUri).then((uriPath) => {
var path = "file://" + uriPath
LogUtil.info(TAG, 'image uri is:' + path)
this.controllerShow.runJavaScript({
script: "javascript:RICH_EDITOR.insertImage('" + path + "')"
})
this.issave = 1
// 保存笔记信息到数据库
this.controllerShow.runJavaScript({script:"getHtmlContent()"})
})
}
}
});
})
}.width(42)
.height(42)
.borderRadius(8)
.backgroundColor($r('app.color.color_fffffB'))
Button({ type: ButtonType.Normal, stateEffect: true }) {
Image($r('app.media.undo'))
.height(24)
@@ -491,7 +473,7 @@ export struct NoteContentOverViewComp {
justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
Row() {
Text(this.selectedNoteData.title)
.id(this.isUpdate+'')
.id(this.isUpdate + '')
.fontSize(30)
.margin({ left: 12, right: 24 })
.onClick(() => {
@@ -54,19 +54,29 @@ export struct NoteContentComp {
@Consume('LastSectionStatus') lastSectionStatus: number
@Consume('Issave') issave: number
@Consume('Search') search: boolean
@StorageLink('dpi') dpi: number = 240
controllerShow: WebController
private editContentFlag = false
@State uri1: string = ""
private context = getContext(this)
@StorageLink('ScrollTopPercent') scrollTopPercent: number = 0.0
@StorageLink('isUpdate') isUpdate: boolean = false
@StorageLink('refreshCurrentNote')@Watch('isDataChange') refreshCurrentNote: boolean = false
@StorageLink('refreshCurrentNote') @Watch('isDataChange') refreshCurrentNote: boolean = false
editContentDialogCtl: CustomDialogController = new CustomDialogController({
builder: EditContentDialog({ confirm: this.confirm.bind(this) }),
alignment: DialogAlignment.Bottom,
autoCancel: true,
customStyle: true,
})
confirm(excuteJs: string) {
this.controllerShow.runJavaScript({ script: excuteJs })
}
isDataChange() {
if (!this.refreshCurrentNote) {
return
}
this.controllerShow.runJavaScript({script:"RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')"})
this.controllerShow.runJavaScript({ script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')" })
this.refreshCurrentNote = false
}
@@ -201,6 +211,55 @@ export struct NoteContentComp {
} else if (fontSize === 48) {
this.selectedNoteData.slider_value = 16
}
},
addToDo: () => {
// 清单
this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.setTodo()" })
// 退出键盘
// @ts-ignore
inputMethod.getController().stopInputSession();
},
chooseStyle: () => {
// 退出键盘
// @ts-ignore
inputMethod.getController().stopInputSession();
this.editContentDialogCtl.open()
},
openAlbum: async () => {
// 退出键盘
// @ts-ignore
inputMethod.getController().stopInputSession();
LogUtil.info(TAG, 'startAbility start')
await globalThis.noteContext.startAbilityForResult({
parameters: { uri: "singleselect" },
bundleName: "com.ohos.photos",
abilityName: "com.ohos.photos.MainAbility",
})
.then(v => {
let want = v['want'];
if (want != null && want != undefined) {
let param = want['parameters'];
let imageUri = ""
if (param != null && param != undefined) {
let uri = param['select-item-list'];
imageUri = uri;
}
// 拷贝
if (imageUri != null && imageUri != "") {
OperationUtils.copy(imageUri).then((uriPath) => {
var path = "file://" + uriPath
LogUtil.info(TAG, 'image uri is:' + path)
this.controllerShow.runJavaScript({
script: "javascript:RICH_EDITOR.insertImage('" + path + "')"
})
this.issave = 1
// 保存笔记信息到数据库
this.controllerShow.runJavaScript({ script: "getHtmlContent()" })
})
}
}
NoteUtil.refreshAll()
});
}
}
@@ -223,10 +282,17 @@ export struct NoteContentComp {
.javaScriptProxy({
object: this.noteContent,
name: "callBackToApp", // html--> name.method
methodList: ["callbackhtml", "callbackhtmlSave", "callbackScheduledSave", "callbackGetSize", "callbackPasteImage", "callbackImagePath"],
methodList: ["callbackhtml", "callbackhtmlSave", "callbackScheduledSave", "callbackGetSize", "callbackPasteImage", "callbackImagePath", "addToDo", "chooseStyle", "openAlbum"],
controller: this.controllerShow
})
.onPageEnd((e) => {
if (this.dpi <= 240) {
this.controllerShow.runJavaScript({ script: "changeSizeToRk()" })
} else if (this.dpi >= 320 && this.dpi > 240) {
this.controllerShow.runJavaScript({ script: "changeSizeToPhone()" })
} else {
this.controllerShow.runJavaScript({ script: "changeSizeToTablet()" })
}
LogUtil.info(TAG, "finish loadurl")
if (this.selectedNoteData) {
let self = this
@@ -275,7 +341,7 @@ export struct NoteContentComp {
clearInterval(timeId)
}
timeId = setInterval(() => {
this.controllerShow.runJavaScript({ script: "scheduledSaveContent()" })
this.controllerShow.runJavaScript({ script: "scheduledSaveContent()" })
}, 3000)
LogUtil.info(TAG, "setInterval timeId : " + timeId)
// save continue data
@@ -394,7 +460,7 @@ export struct NoteContentOverViewComp {
justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
Row() {
Text(this.selectedNoteData.title)
.id(this.isUpdate+'')
.id(this.isUpdate + '')
.fontSize(30)
.margin({ left: 0, right: 24 })
.onClick(() => {
@@ -491,17 +557,6 @@ export struct ToolBarComp {
AppStorage.SetOrCreate('isUpdate', true)
}
editContentDialogCtl: CustomDialogController = new CustomDialogController({
builder: EditContentDialog({ confirm: this.confirm.bind(this) }),
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 }) {
@@ -589,83 +644,6 @@ export struct ToolBarComp {
}.width(72)
} else if (this.editModel == true) {
Row({ space: StyleConstants.SPACE_6 }) {
Button({ type: ButtonType.Normal, stateEffect: true }) {
Image($r('app.media.circle_tick1'))
.height(24)
.width(24)
.onClick(() => {
// 清单
this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.setTodo()" })
// 退出键盘
// @ts-ignore
inputMethod.getController().stopInputSession();
})
}.width(42)
.height(42)
.borderRadius(8)
.backgroundColor($r('app.color.color_fffffB'))
Button({ type: ButtonType.Normal, stateEffect: true }) {
Image($r('app.media.styles'))
.height(24)
.width(24)
.onClick(() => {
// 退出键盘
// @ts-ignore
inputMethod.getController().stopInputSession();
this.editContentDialogCtl.open()
})
}.width(42)
.height(42)
.borderRadius(8)
.backgroundColor($r('app.color.color_fffffB'))
Button({ type: ButtonType.Normal, stateEffect: true }) {
Image($r('app.media.picture_white'))
.height(24)
.width(24)
.onClick(async () => {
// 退出键盘
// @ts-ignore
inputMethod.getController().stopInputSession();
LogUtil.info(TAG, 'startAbility start')
await globalThis.noteContext.startAbilityForResult({
parameters: { uri: "singleselect" },
bundleName: "com.ohos.photos",
abilityName: "com.ohos.photos.MainAbility",
})
.then(v => {
let want = v['want'];
if (want != null && want != undefined) {
let param = want['parameters'];
let imageUri = ""
if (param != null && param != undefined) {
let uri = param['select-item-list'];
imageUri = uri;
}
// 拷贝
if (imageUri != null && imageUri != "") {
OperationUtils.copy(imageUri).then((uriPath) => {
var path = "file://" + uriPath
LogUtil.info(TAG, 'image uri is:' + path)
this.controllerShow.runJavaScript({
script: "javascript:RICH_EDITOR.insertImage('" + path + "')"
})
this.issave = 1
// 保存笔记信息到数据库
this.controllerShow.runJavaScript({script:"getHtmlContent()"})
})
}
}
NoteUtil.refreshAll()
});
})
}.width(42)
.height(42)
.borderRadius(8)
.backgroundColor($r('app.color.color_fffffB'))
Button({ type: ButtonType.Normal, stateEffect: true }) {
Image($r('app.media.undo'))
.height(24)
@@ -56,10 +56,20 @@ export struct NoteContentCompPortrait {
@Provide('SelectedFolderData') selectedFolderData: FolderData = AppStorage.Get("NewFolder")
@StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray')
@Provide('EditModel') editModel: boolean = false
@StorageLink('dpi') dpi: number = 240
controllerShow: WebController
private editContentFlag = false
@StorageLink('ScrollTopPercent') scrollTopPercent: number = 0.0
editContentDialogCtl: CustomDialogController = new CustomDialogController({
builder: EditContentDialogPortrait({ confirm: this.confirm.bind(this) }),
alignment: DialogAlignment.Bottom,
autoCancel: true,
customStyle: true,
})
confirm(excuteJs: string) {
this.controllerShow.runJavaScript({ script: excuteJs })
}
storeScrollTop(scrollTop: number) {
if (scrollTop < 0) {
return
@@ -170,6 +180,40 @@ export struct NoteContentCompPortrait {
} else if (fontSize === 48) {
this.selectedNoteData.slider_value = 16
}
},
addToDo: () => {
// 清单
this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.setTodo()" })
},
chooseStyle: () => {
this.editContentDialogCtl.open()
},
openAlbum: async () => {
LogUtil.info(TAG, 'startAbility start')
await globalThis.noteContext.startAbilityForResult({
parameters: { uri: "singleselect" },
bundleName: "com.ohos.photos",
abilityName: "com.ohos.photos.MainAbility",
}).then(v => {
let want = v['want'];
if (want != null && want != undefined) {
let param = want['parameters'];
let imageUri = ""
if (param != null && param != undefined) {
let uri = param['select-item-list'];
imageUri = uri;
}
LogUtil.info(TAG, "image url" + imageUri)
// 拷贝
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 + "')" })
})
}
}
});
}
}
@@ -188,10 +232,17 @@ export struct NoteContentCompPortrait {
.javaScriptProxy({
object: this.noteContent,
name: "callBackToApp", // html--> name.method
methodList: ["callbackhtml", "callbackScheduledSave", "callbackPasteImage", "callbackImagePath", "callbackGetSize"],
methodList: ["callbackhtml", "callbackScheduledSave", "callbackPasteImage", "callbackImagePath", "callbackGetSize", "addToDo", "chooseStyle", "openAlbum"],
controller: this.controllerShow
})
.onPageEnd((e) => {
if (this.dpi <= 240) {
this.controllerShow.runJavaScript({ script: "changeSizeToRk()" })
} else if (this.dpi >= 320 && this.dpi > 240) {
this.controllerShow.runJavaScript({ script: "changeSizeToPhone()" })
} else {
this.controllerShow.runJavaScript({ script: "changeSizeToTablet()" })
}
LogUtil.info(TAG, "finish loadurl")
let self = this
this.controllerShow.runJavaScript({
@@ -223,7 +274,7 @@ export struct NoteContentCompPortrait {
}
// 添加定时器:3s自动保存
time_id = setInterval(() => {
this.controllerShow.runJavaScript({ script: "scheduledSaveContent()" })
this.controllerShow.runJavaScript({ script: "scheduledSaveContent()" })
}, 3000)
LogUtil.info(TAG, "setInterval time_id : " + time_id)
this.editModel = true
@@ -234,7 +285,6 @@ export struct NoteContentCompPortrait {
.flexShrink(1)
.padding({ left: 24, right: 24 })
EditNoteCompForPortrait({ controllerShow: this.controllerShow })
DeleteNoteComp()
}
.height(StyleConstants.PERCENTAGE_100)
@@ -321,7 +371,7 @@ export struct NoteContentOverViewComp {
justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
Row() {
Text(this.selectedNoteData.title)
.id(this.isUpdate+'')
.id(this.isUpdate + '')
.fontSize(30).fontWeight(FontWeight.Medium)
.onClick(() => {
clearInterval(time_id)
@@ -595,114 +645,6 @@ export struct DeleteNoteComp {
}
}
@Component
export struct EditNoteCompForPortrait {
@StorageLink('CheckedNoteArray') CheckedNoteArray: NoteData[] = []
@StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray')
@Consume('SelectedFolderData') selectedFolderData: FolderData
@Consume('SelectedNoteData') selectedNoteData: NoteData;
@Consume('EditModel') editModel: boolean
controllerShow: WebController
editContentDialogCtl: CustomDialogController = new CustomDialogController({
builder: EditContentDialogPortrait({ confirm: this.confirm.bind(this) }),
alignment: DialogAlignment.Bottom,
autoCancel: true,
customStyle: true,
})
confirm(excuteJs: string) {
this.controllerShow.runJavaScript({ script: excuteJs })
}
build() {
Row() {
Column() {
Image($r('app.media.circle_tick1'))
.width(24)
.height(24)
.responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 })
.onClick(() => {
// 清单
this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.setTodo()" })
})
Text($r("app.string.list"))
.fontSize(10)
.fontColor($r('app.color.list_font_color'))
.padding({ top: 5 })
}
.height("100%")
.width(120)
.justifyContent(FlexAlign.Center)
.alignItems(HorizontalAlign.Center)
Column() {
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()
})
Text($r("app.string.style"))
.fontSize(10)
.fontColor($r('app.color.style_font_color'))
.padding({ top: 5 })
}
.height("100%")
.width(120)
.justifyContent(FlexAlign.Center)
.alignItems(HorizontalAlign.Center)
Column() {
Image($r('app.media.picture_white'))
.width(24)
.height(24)
.responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 })
.onClick(async () => {
LogUtil.info(TAG, 'startAbility start')
await globalThis.noteContext.startAbilityForResult({
parameters: { uri: "singleselect" },
bundleName: "com.ohos.photos",
abilityName: "com.ohos.photos.MainAbility",
}).then(v => {
let want = v['want'];
if (want != null && want != undefined) {
let param = want['parameters'];
let imageUri = ""
if (param != null && param != undefined) {
let uri = param['select-item-list'];
imageUri = uri;
}
LogUtil.info(TAG, "image url" + imageUri)
// 拷贝
if (imageUri != null && imageUri != "") {
OperationUtils.copy(imageUri).then((uriPath) => {
var path = "file://" + uriPath
LogUtil.info(TAG, 'image uri is:' + path)
this.controllerShow.runJavaScript({ script: "javascript:RICH_EDITOR.insertImage('" + path + "')" })
})
}
}
});
})
Text($r("app.string.photo"))
.fontSize(10)
.fontColor($r('app.color.photo_font_color'))
.padding({ top: 5 })
}
.height("100%")
.width(120)
.justifyContent(FlexAlign.Center)
.alignItems(HorizontalAlign.Center)
}
.width(360)
.height(56)
.visibility(this.selectedNoteData.is_deleted == Delete.No && this.editModel == true ?
Visibility.Visible : Visibility.None)
}
}
@Component
struct NoteDataMoveItemCompMenu {
@StorageLink('CheckedNoteArray') CheckedNoteArray: NoteData[] = []
@@ -205,6 +205,7 @@ export default class MainAbility extends Ability {
let screenDpi = null
displayClass = display.getDefaultDisplaySync()
screenDpi = displayClass.densityDPI
AppStorage.SetOrCreate('dpi', screenDpi)
let windowWidth = data / (screenDpi / 160)
LogUtil.debug(this.Tag, " screenBreakPoints windowWidth: " + windowWidth)
if (windowWidth >= 320 && windowWidth < 520 || windowWidth < 320) {