This commit is contained in:
shaoyongjun 2024-10-31 20:39:28 +08:00
parent 4f675f46b2
commit 6fd9b831e2
2 changed files with 44 additions and 30 deletions

View File

@ -162,7 +162,7 @@ export class MyBiz {
//rowNo //rowNo
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);
let empListIsEmpty = (emptyRowNoList === undefined || emptyRowNoList === null || emptyRowNoList.length <= 0); let empListIsEmpty = (emptyRowNoList === undefined || emptyRowNoList === null || emptyRowNoList.length <= 0);
if (!empListIsEmpty) { if (!empListIsEmpty) {
let tmpArr = []; let tmpArr = [];
@ -243,18 +243,18 @@ export class MyBiz {
let curP = window.myEdit.utils.GetEventTarget(event); let curP = window.myEdit.utils.GetEventTarget(event);
let myDocItem = new MyDocItem(curP); let myDocItem = new MyDocItem(curP);
let inputLength = curP.innerText.length let inputLength = curP.innerText.length
console.log("emptyKeyWorkHandler :", curP, " _'", curP.innerHTML, "'_'", curP.innerText, "'_", // console.log("emptyKeyWorkHandler :", curP, " _'", curP.innerHTML, "'_'", curP.innerText, "'_",
"\neq1", curP.innerHTML.startsWith("&nbsp;#&nbsp;"), // "\neq1", curP.innerHTML.startsWith("&nbsp;#&nbsp;"),
"\neq2", curP.innerHTML.startsWith(" # "), // "\neq2", curP.innerHTML.startsWith(" # "),
"\neq3", curP.innerHTML.startsWith("#&nbsp;"), // "\neq3", curP.innerHTML.startsWith("#&nbsp;"),
"\neq4", curP.innerHTML.startsWith("# "), // "\neq4", curP.innerHTML.startsWith("# "),
//
"\neqV1", curP.innerText.startsWith("&nbsp;#&nbsp;"), // "\neqV1", curP.innerText.startsWith("&nbsp;#&nbsp;"),
"\neqV2", curP.innerText.startsWith(" # "), // "\neqV2", curP.innerText.startsWith(" # "),
"\neqV3", curP.innerText.startsWith("#&nbsp;"), // "\neqV3", curP.innerText.startsWith("#&nbsp;"),
"\neqV4", curP.innerText.startsWith("# "), // "\neqV4", curP.innerText.startsWith("# "),
//
) // )
/** /**
* h1 ~ h6 * h1 ~ h6
*/ */
@ -410,18 +410,18 @@ export class MyBiz {
start = end; start = end;
end = tmpS; end = tmpS;
} }
console.log(" 当前选区信息 : ", curSec, // console.log(" 当前选区信息 : ", curSec,
"\ncurPe: ", curPe, // "\ncurPe: ", curPe,
"\ncurPeP: ", curPe.parentNode, curPe.parentNode.nodeType, curPe.parentNode.nodeName, // "\ncurPeP: ", curPe.parentNode, curPe.parentNode.nodeType, curPe.parentNode.nodeName,
//
"\ncurPeIsP: ", curPeIsP, // "\ncurPeIsP: ", curPeIsP,
"\ncurPeParentIsP : ", curPeParentIsP, // "\ncurPeParentIsP : ", curPeParentIsP,
"\ncurPeParentIsDIV", curPeParentIsDIV, // "\ncurPeParentIsDIV", curPeParentIsDIV,
"\ncurPeParentIsSpan", curPeParentIsSpan, // "\ncurPeParentIsSpan", curPeParentIsSpan,
//
"\nclassName: ", className, // "\nclassName: ", className,
"\ntart: ", start, // "\ntart: ", start,
"\nend: ", end) // "\nend: ", end)
let curPEle = null; let curPEle = null;
//第一次选择的时候将整行转换成<p><span></span></p> //第一次选择的时候将整行转换成<p><span></span></p>
@ -433,7 +433,7 @@ export class MyBiz {
// div // div
} }
let curStartP = curSec.startContainer.parentElement; let curStartP = curSec.startContainer.parentElement;
console.log("debug1: ", curStartP, curStartP.nodeType, curStartP.nodeName) // console.log("debug1: ", curStartP, curStartP.nodeType, curStartP.nodeName)
//维护最近一次编辑的内容(暂时只支持恢复最近一次编辑) //维护最近一次编辑的内容(暂时只支持恢复最近一次编辑)
window.myEdit.ctx.latestOpDoc = new MyRecovery(curStartP.cloneNode(true), function () { window.myEdit.ctx.latestOpDoc = new MyRecovery(curStartP.cloneNode(true), function () {
console.log("恢复上一步样式1", this.innerHTML) console.log("恢复上一步样式1", this.innerHTML)
@ -474,7 +474,7 @@ export class MyBiz {
if (!curPeIsP && curPeParentIsSpan) { if (!curPeIsP && curPeParentIsSpan) {
tmpPNode = curSec.commonAncestorContainer.parentNode.parentNode; tmpPNode = curSec.commonAncestorContainer.parentNode.parentNode;
} }
console.log("debug2: ", curSec.commonAncestorContainer, tmpPNode, tmpPNode.children, tmpPNode.childNodes) // console.log("debug2: ", curSec.commonAncestorContainer, tmpPNode, tmpPNode.children, tmpPNode.childNodes)
//维护最近一次编辑的内容(暂时只支持恢复最近一次编辑) //维护最近一次编辑的内容(暂时只支持恢复最近一次编辑)
window.myEdit.ctx.latestOpDoc = new MyRecovery(tmpPNode.cloneNode(true), function () { window.myEdit.ctx.latestOpDoc = new MyRecovery(tmpPNode.cloneNode(true), function () {
console.log("恢复上一步样式1", this.data) console.log("恢复上一步样式1", this.data)

View File

@ -44,7 +44,7 @@ export class MyEventListener {
//删除 //删除
if (keyCode === 46 || keyCode === 8) { if (keyCode === 46 || keyCode === 8) {
window.myEdit.biz.deleteHandle(event); // window.myEdit.biz.deleteHandle(event);
return; return;
} }
@ -57,7 +57,7 @@ export class MyEventListener {
//空格键 //空格键
if (keyCode === 32) { if (keyCode === 32) {
console.log('触发 空格 事件', e.target) console.log('触发 空格 事件', e.target)
window.myEdit.biz.emptyKeyWorkHandler(event); // window.myEdit.biz.emptyKeyWorkHandler(event);
return; return;
} }
} }
@ -85,6 +85,12 @@ export class MyEventListener {
if (keyCode === 13) { if (keyCode === 13) {
window.myEdit.utils.ProhibitDefaultEvent(event); window.myEdit.utils.ProhibitDefaultEvent(event);
} }
//在鼠标按下的时候删除,体验更好
if (keyCode === 46 || keyCode === 8) {
window.myEdit.biz.deleteHandle(event);
return;
}
} }
/** /**
@ -94,8 +100,16 @@ export class MyEventListener {
*/ */
InputListener(e) { InputListener(e) {
const event = window.myEdit.utils.ParseEvent(e); const event = window.myEdit.utils.ParseEvent(e);
console.log("input : ", event) // console.log("input : ", event, " text: '", event.data + "'")
let testDiv = document.getElementById("testDevice")
testDiv.innerText = testDiv.innerText +
"\n输入内容: '" + (event.data === " ") + "'";
window.myEdit.biz.inputHandle(event); window.myEdit.biz.inputHandle(event);
//处理空行转换
if (event.data === " ") {
window.myEdit.biz.emptyKeyWorkHandler(event);
}
} }
/** /**