fix: 回车跳到多行之后

This commit is contained in:
shaoyongjun 2024-10-31 16:11:12 +08:00
parent 924174210f
commit 50b0824b5a
2 changed files with 26 additions and 9 deletions

View File

@ -163,7 +163,21 @@ export class MyBiz {
let rowNo = 0; let rowNo = 0;
let emptyRowNoList = window.myEdit.ctx.MyDocMap.get("emptyRowNoList"); let emptyRowNoList = window.myEdit.ctx.MyDocMap.get("emptyRowNoList");
console.log(emptyRowNoList); console.log(emptyRowNoList);
if (emptyRowNoList === undefined || emptyRowNoList === null) { let empListIsEmpty = (emptyRowNoList === undefined || emptyRowNoList === null || emptyRowNoList.length <= 0);
if (!empListIsEmpty) {
let tmpArr = [];
for (let i = 0; i < emptyRowNoList.length; i++) {
let tmpNo = emptyRowNoList[i];
if (window.myEdit.ctx.getMapItem(tmpNo).getHidden()) {
tmpArr.push(emptyRowNoList[i]);
}
}
window.myEdit.ctx.MyDocMap.set("emptyRowNoList", tmpArr);
empListIsEmpty = tmpArr.length <= 0;
emptyRowNoList = tmpArr
}
if (empListIsEmpty) {
rowNo = window.myEdit.ctx.incrementNumThenReturn(); rowNo = window.myEdit.ctx.incrementNumThenReturn();
//添加新元素 //添加新元素
let newParagraph = document.createElement("p") let newParagraph = document.createElement("p")
@ -213,7 +227,8 @@ export class MyBiz {
return return
} }
mapItem.setSource(curP.innerText) mapItem.setSource(curP.innerText);
mapItem.setHidden(false);
// console.log("curPTx: ", curP.innerText, "MyDocMap : ", utils.MyDocMap) // console.log("curPTx: ", curP.innerText, "MyDocMap : ", utils.MyDocMap)
//显示用户的输入内容 //显示用户的输入内容
@ -305,7 +320,7 @@ export class MyBiz {
mapNode.getStyle().setPreStyle("ol", preContent) mapNode.getStyle().setPreStyle("ol", preContent)
//clean //clean
let historyContent = curP.innerHTML.replace(preContent+".", ""); let historyContent = curP.innerHTML.replace(preContent + ".", "");
mapNode.setSource(curP.innerText) mapNode.setSource(curP.innerText)
//todo //todo
curP.setAttribute("style", "padding-left: 1rem;") curP.setAttribute("style", "padding-left: 1rem;")

View File

@ -297,14 +297,16 @@ export class MyUtils {
RefreshBodyFrontSize() { RefreshBodyFrontSize() {
let dpr = window.devicePixelRatio || 1;//当前设置下 物理像素和虚拟像素的比值 let dpr = window.devicePixelRatio || 1;//当前设置下 物理像素和虚拟像素的比值
let defaultFrontSize = window.myEdit.ctx.bodyFrontSize; let defaultFrontSize = window.myEdit.ctx.bodyFrontSize;
if(!dpr){ if (!dpr) {
let isAndroid = win.navigator.appVersion.match(/android/gi); //devicePixelRatio这个属性是可以获取到设备的dpr
let isIPhone = win.navigator.appVersion.match(/iphone/gi); let devicePixelRatio = win.devicePixelRatio;
if (isIPhone) {//只对iPhone做了处理 //判断dpr是否为整数
// iOS下对于2和3的屏用2倍的方案其余的用1倍方案 let isRegularDpr = devicePixelRatio.toString().match(/^[1-9]\d*$/g)
if (isRegularDpr) {
// 对于是整数的dpr对dpr进行操作
if (devicePixelRatio >= 3 && (!dpr || dpr >= 3)) { if (devicePixelRatio >= 3 && (!dpr || dpr >= 3)) {
dpr = 3; dpr = 3;
} else if (devicePixelRatio >= 2 && (!dpr || dpr >= 2)){ } else if (devicePixelRatio >= 2 && (!dpr || dpr >= 2)) {
dpr = 2; dpr = 2;
} else { } else {
dpr = 1; dpr = 1;