This commit is contained in:
shaoyongjun 2024-10-31 15:52:17 +08:00
parent 1dc0506b01
commit 924174210f
5 changed files with 46 additions and 24 deletions

View File

@ -44,15 +44,19 @@ header {
#noteshare {
width: 90%;
/* width: 21cm; */
min-height: 160rem;
min-height: 2000rem;
/* font-size: 1.5rem; */
/*border: 1px red solid;*/
margin: auto auto;
padding: 100rem 100rem;
/*box-shadow: 0 40rem 80rem rgba(31, 35, 41, 0.1);*/
/*响应式*/
display: flex;
flex-wrap: wrap;
/*display: flex;*/
/*flex-direction:column;*/
/*flex-wrap: nowrap;*/
}
#noteshare p {
@ -112,11 +116,11 @@ header {
.fixStylePosition {
display: none;
position: fixed;
z-index: 87;
z-index: 99;
width: auto;
height: 240rem;
height: 340rem;
padding: 80rem 80rem;
padding: 30rem 30rem;
/*padding: 0.6rem 1rem 0.6rem 1rem;*/
justify-content: center;
align-items: center;

View File

@ -297,6 +297,24 @@ export class MyUtils {
RefreshBodyFrontSize() {
let dpr = window.devicePixelRatio || 1;//当前设置下 物理像素和虚拟像素的比值
let defaultFrontSize = window.myEdit.ctx.bodyFrontSize;
if(!dpr){
let isAndroid = win.navigator.appVersion.match(/android/gi);
let isIPhone = win.navigator.appVersion.match(/iphone/gi);
if (isIPhone) {//只对iPhone做了处理
// iOS下对于2和3的屏用2倍的方案其余的用1倍方案
if (devicePixelRatio >= 3 && (!dpr || dpr >= 3)) {
dpr = 3;
} else if (devicePixelRatio >= 2 && (!dpr || dpr >= 2)){
dpr = 2;
} else {
dpr = 1;
}
} else {
// 其他设备下仍旧使用1倍的方案
dpr = 1;
}
}
document.body.style.fontSize = defaultFrontSize * dpr + 'px';
console.log("body-frontSize: ", document.body.style.fontSize);
}

View File

@ -125,6 +125,7 @@ export class MyEventListener {
MouseUp(e) {
let styleUtils = document.getElementById("_style_utils");
if (window.myEdit.utils.GetSelection().isCollapsed) {
console.log("none")
styleUtils.style.display = "none";
return
}

View File

@ -24,7 +24,7 @@ import {MyEventListener} from "./event/MyEventListener.js";
/**
* 默认body front-size 单位px
*/
bodyFrontSize: 12,
bodyFrontSize: 14,
/**
* 设计稿宽度 375
*/
@ -113,12 +113,6 @@ import {MyEventListener} from "./event/MyEventListener.js";
* 加载完成后执行
*/
window.onload = function () {
//这里监听鼠标按下事件
document.getElementById("_style_utils").addEventListener("mousedown", function (e) {
const event = window.myEdit.utils.ParseEvent(e);
window.myEdit.utils.ProhibitDefaultEvent(event);
}, true);
//样式事件监听
let styleList = document.getElementsByClassName("fixStyleInnerSpan");
console.log("styleList : ", styleList);
@ -154,5 +148,11 @@ window.onload = function () {
//监听鼠标抬起事件
document.getElementById("noteshare").addEventListener("mouseup", window.myEdit.eventListener.MouseUp, true);
//这里监听鼠标按下事件
document.getElementById("_style_utils").addEventListener("mousedown", function (e) {
const event = window.myEdit.utils.ParseEvent(e);
console.log("mousedown: ", event)
window.myEdit.utils.ProhibitDefaultEvent(event);
}, false);
}

View File

@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>📒</title>
<meta name="viewport"
content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height"/>
content="width=device-width, height=device-height,initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<link rel="stylesheet" type="text/css" href="./css/normalize.css">
<link rel="stylesheet" type="text/css" href="./css/myEdit.css">
<script type="module" src="./js/lib/main.js"></script>
@ -16,6 +16,15 @@
<body style="display: flex; flex-direction:column; background-color: #ffebc3">
<header>
</header>
<main style="margin-top: 150rem; display: flex; flex-direction:column; align-items:center;">
<h3>测试编辑</h3>
<div id="noteshare" spellcheck="false" translate="no">
</div>
</main>
<footer>
<div class="fixStylePosition" id="_style_utils">
<div class="fixStyleOut">
<div style="display: flex;">
@ -115,18 +124,8 @@
<!-- </div>-->
</div>
</div>
</header>
<main style="margin-top: 500rem; display: flex;flex-direction:column;align-items:center;">
<h3>测试编辑</h3>
<div id="noteshare" spellcheck="false" translate="no">
</div>
</main>
<footer>
<!-- <div id="testInput" >测试</div>-->
</footer>
</body>
</html>