to:sync
This commit is contained in:
parent
971a70e566
commit
cacae7d7d8
@ -48,14 +48,15 @@ define(function (require, exports, module) {
|
|||||||
|
|
||||||
function addNewP(mutation) {
|
function addNewP(mutation) {
|
||||||
let target = mutation.target;
|
let target = mutation.target;
|
||||||
|
// target.clone()
|
||||||
if (target.nodeName === "DIV" && mutation.previousSibling !== null) {
|
if (target.nodeName === "DIV" && mutation.previousSibling !== null) {
|
||||||
let targetP = mutation.previousSibling.nextSibling;
|
let newParagraph = mutation.previousSibling.nextSibling;
|
||||||
console.log(
|
console.log(
|
||||||
"addNewP target: ", target,
|
"addNewP target: ", target,
|
||||||
"\nnodeType: ", target.nodeType,
|
"\nnodeType: ", target.nodeType,
|
||||||
"\nnodeName: ", target.nodeName,
|
"\nnodeName: ", target.nodeName,
|
||||||
"\ndata: ", target.value,
|
"\ndata: ", target.value,
|
||||||
"\n next: ", targetP
|
"\n next: ", newParagraph
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -64,11 +65,11 @@ define(function (require, exports, module) {
|
|||||||
if (ctx.getCurRowNo() === 0) {
|
if (ctx.getCurRowNo() === 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (targetP !== undefined && targetP !== null) {
|
if (newParagraph !== undefined && newParagraph !== null) {
|
||||||
targetP.id = utils.Uuid(ctx.usn, ctx.docType);
|
newParagraph.id = utils.Uuid(ctx.usn, ctx.docType);
|
||||||
targetP.setAttribute("data-order", ctx.incrementNumThenReturn());
|
newParagraph.setAttribute("data-order", ctx.incrementNumThenReturn());
|
||||||
|
|
||||||
let newParagraph = document.getElementById(targetP.id);
|
// let newParagraph = document.getElementById(targetP.id);
|
||||||
//前置 span
|
//前置 span
|
||||||
let preSpan = newParagraph.querySelector("span[data-flag='span_pre']");
|
let preSpan = newParagraph.querySelector("span[data-flag='span_pre']");
|
||||||
if (preSpan === undefined || preSpan === null) {
|
if (preSpan === undefined || preSpan === null) {
|
||||||
@ -76,6 +77,8 @@ define(function (require, exports, module) {
|
|||||||
preSpan.setAttribute("contenteditable", "false")
|
preSpan.setAttribute("contenteditable", "false")
|
||||||
preSpan.setAttribute("data-flag", "span_pre")
|
preSpan.setAttribute("data-flag", "span_pre")
|
||||||
newParagraph.appendChild(preSpan);
|
newParagraph.appendChild(preSpan);
|
||||||
|
} else {
|
||||||
|
console.log("newParagraph preSpan exist ", newParagraph," ",preSpan)
|
||||||
}
|
}
|
||||||
|
|
||||||
//内置span
|
//内置span
|
||||||
@ -85,16 +88,10 @@ define(function (require, exports, module) {
|
|||||||
spanContent.append(document.createElement("br"));
|
spanContent.append(document.createElement("br"));
|
||||||
spanContent.setAttribute("data-flag", "span_content")
|
spanContent.setAttribute("data-flag", "span_content")
|
||||||
newParagraph.appendChild(spanContent);
|
newParagraph.appendChild(spanContent);
|
||||||
|
} else {
|
||||||
|
console.log("newParagraph preSpan spanContent ", newParagraph)
|
||||||
}
|
}
|
||||||
|
|
||||||
// newParagraph.innerHTML = '<span contenteditable="false" data-flag="span_pre"></span><span data-flag="span_content"><br/></span>'
|
|
||||||
|
|
||||||
// newParagraph.insertAdjacentHTML('beforeend',
|
|
||||||
// '<span contenteditable="false" data-flag="span_pre"></span><span data-flag="span_content"><br></span>');
|
|
||||||
console.log("newParagraph addChildren ", newParagraph)
|
|
||||||
//收起选区到一个点,光标落在一个可编辑元素上
|
|
||||||
// utils.GetSelection().removeAllRanges();
|
|
||||||
// utils.GetSelection().setPosition(newParagraph, 0);
|
|
||||||
utils.GetSelection().setPosition(spanContent, 0);
|
utils.GetSelection().setPosition(spanContent, 0);
|
||||||
spanContent.focus();
|
spanContent.focus();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user